Problem Description: I want to configure AdminPath in a unified configuration, it is convenient to configure the permissions later, so I want to map to ${adminpath} after @requestmapping, but the value is not obtained here.
* *
user Controller
* @author thinkgem
* @version 2013-8-29
*
/@Controller @RequestMapping ( Value = "${adminpath}/sys/user") public
class Usercontroller extends Basecontroller {
@Autowired
private UserService userservice;
@Value ("${adminpath}")
private String password;
@ResponseBody
@RequiresPermissions ("Sys:user:view")
@RequestMapping (value = {"ListData"})
Public Page<user> listData (user user, HttpServletRequest request, httpservletresponse response, model model) {
Page <User> page = Userservice.finduser (new page<user> (request, response), User);
SYSTEM.OUT.PRINTLN ("Password as:" +password);
return page;
}
}
Known: @Value annotations can get the values in the properties file.
If you add a configuration <util:properties> tag, you can get the value by @value ("#{app_prop[' Jdbc.driver '}"). At this point, the value cannot still be taken from @value ("${adminpath}").
<!--load an instance of the App property, which can be referenced by a String jdbcdriver @Value ("#{app_prop[' Jdbc.driver '}")-
<util:properties Id= "App_prop" location= "Classpath*:test01.properties" local-override= "true"/>
I would like to take the value from the properties file by adding the following configuration through the $ character.
<!--load Configuration Properties File--
<context:property-placeholder ignore-unresolvable= "true" location= "classpath*: Test01.properties "/>
Note: In this way, if you have the following configuration in the Spring-mvc.xml file, you must not be missing the following red section:
The function and principle analysis of use-default-filters attribute of Context:component-scan tag
<!--configuring component scans, SPRINGMVC only controller annotations--
use-default-filters= "false">
<context: Include-filter type= "Annotation" expression= "Org.springframework.stereotype.Controller"/> </context
: Component-scan>
After I have added the Use-default-filters property, you can get the desired value through the $ symbol.
For more information, please refer to the article: Five Ways to read the properties file content in Java is no longer a challenge