作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在某些情况下,我看到有两种不同的方式在 @RequestMapping
中指定 uri:
@RequestMapping(value="/somepath")
@RequestMapping("/somepath")
后者通常在类级别使用。那么,省略 value
属性总是合法的吗?
最佳答案
It is legal to use single-element annotations for annotation types with multiple elements, so long as one element is named value, and all other elements have default values.
由于 @RequestMapping
具有定义的 value
属性,并且所有其他属性都有默认值(空数组),因此省略名称 value 的拼写始终是合法的
如果您没有为注释指定任何其他属性:
@RequestMapping("/somepath") // valid
@RequestMapping("/somepath", method = RequestMethod.GET) // INVALID!
关于java - Spring @RequestMapping 值显式/隐式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19176393/
我是一名优秀的程序员,十分优秀!