除了URI templates,@RequestMapping 也支持Ant-style的路徑模式,例如:/myPath/*.do .
URI templates
和
Ant-style 混合的支持,例如:/owners/*/pets/{petId}。
@RequestMapping也支持 類似於${…}佔位符,取自本地properties配置文件,system properties配置文件或者是environment variables。
這個在路徑需要自定義的情況下非常有用,對於這個更多的信息,請參考PropertyPlaceholderConfigurer類的API.
下面給出一個例子:
Springmvc.xml配置文件:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="fileEncoding" value="utf-8" />
<property name="locations">
<list>
<value>classpath:url.properties</value>
</list>
</property>
</bean>
@Controller
public class TestController2 {
@RequestMapping(value="${testUrl}")
public String testUrl(){
return "test2";
}
}
url.properties配置文件:
testUrl=/testUrl