从配置文件中获取值为null|struts2配置文件依赖注入参数对应的action类的相应属性是null怎么办

|

1. struts2配置文件依赖注入参数对应的action类的相应属性是null怎么办

问题就出在get方法中,struts2是基于依赖注入的,因此struts2内部已经提供了自动注入机制了,就不需要通过ServletActionContext.getServletContext().getRealPath获取所注入的值,将get方法改为public String getSavePath() throws Exception{ return savePath; }就OK了,望采纳!

2. SpringBoot项目使用@PropertySource注解加载properties配置文件,但输出对象值为null

不是要加上前缀?@ConfigurationProperties(prefix = "Example")@PropertySource("classpath:my.properties")//这是属性文件路径


赞 (0)