传智Struts2笔记(5)为Action的属性注入值
Struts2为Action中的属性提供了依赖注入功能,在struts2的配置文件中,我们可以很方便地为Action中的属性注入值。注意:属性必须提供setter方法。
public class HelloWorldAction{private String savePath;public String getSavePath() {return savePath;}public void setSavePath(String savePath) {this.savePath = savePath;} ......}<package name="itcast" namespace="/test" extends="struts-default"><action name="helloworld" ><param name="savePath">/images</param><result name="success">/WEB-INF/page/hello.jsp</result></action></package>