读书人

替Action属性注入值

发布时间: 2012-08-25 10:06:20 作者: rapoo

为Action属性注入值

当一些属性不适合固定的写入时适合使用这种方式。
要为某一个属性提供set方法,如果需要使用则同样要提供get方法。

?

public class HelloWorldAction{private String savePath;public void setSavePath(String savePath){this.savePath = savePath;}public String getSavePath(){return this.savePath;}}

?参数的注入如result类型中param...一样

<action name="helloWorldAction"><param name="savePath">d:</param><result name="input">/input.jsp</result><result>/success.jsp</result></action>

?

?

这样就可以为HelloWorldAction注入savePath的参数值“D:”

读书人网 >软件架构设计

热点推荐