请问下面的name项是什么意思?
@RequestMapping(value="/getProduct",name="产品中心",method=RequestMethod.GET)
请问下面的name项是什么意思?
@RequestMapping(value="/getProduct",name="产品中心",method=RequestMethod.GET)
接口名字。
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Mapping
public @interface RequestMapping {
/**
* Assign a name to this mapping.
* <p><b>Supported at the type level as well as at the method level!</b>
* When used on both levels, a combined name is derived by concatenation
* with "#" as separator.
* @see org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder
* @see org.springframework.web.servlet.handler.HandlerMethodMappingNamingStrategy
*/
String name() default "";
}
8 回答6.6k 阅读
4 回答714 阅读✓ 已解决
2 回答3.4k 阅读
3 回答1.9k 阅读✓ 已解决
1 回答2.2k 阅读✓ 已解决
1 回答2.1k 阅读✓ 已解决
1 回答974 阅读✓ 已解决
SpringMVC 4.0开始支持基于name值来构建访问的url,需要通过配置AbstractHandlerMethodMapping.,具体接口是HandlerMethodMappingNamingStrategy。
你可以自定义name属性,默认制是通过类的大写字符+#+方法名构建的,比如TestController的getUser方法,name值默认为TC#getUser。
使用上,官方说明是主要可以通过使用Spring jsp tag包里面的mvcUrl,来生成jsp到controller的链接
JSP页面
感觉上比之前自己拼装URL(pageContext.request.contextPath)简单靠谱一点