1

你知道我们可以在 Spring mvc xml 文件中使用属性文件数据。例如:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
<property name="location"> 
<value>xxxx.properties</value> 
</property> 
</bean>

...
<mvc:mapping path="/${path}/*" />
...

但是我如何在注释中使用它,例如:

@Controller
@RequestMapping("/${url}")

现在错了。

告诉我怎么做 非常感谢。

4

1 回答 1

1

Spring doesnt resolve ${x} inside @RequestMapping, indeed {x} is used for @PathVariable. It's not possible to pass non-constant variables to annotations so you can't use @Value either.

I believe its not possible to do what you intend through annotations.

于 2012-07-18T09:27:24.227 回答