首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

传智Struts2札记(5)为Action的属性注入值

2012-11-11 
传智Struts2笔记(5)为Action的属性注入值Struts2为Action中的属性提供了依赖注入功能,在struts2的配置文件

传智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>

上面通过<param>节点为action的savePath属性注入“/images”

热点排行