目录结构:
package cn.ac.siat.helloaction; import com.opensymphony.xwork2.ActionSupport; public class HelloAction extends ActionSupport { private String message; //struts2的默认执行方法 public String execute(){ System.out.println("execute()..."); message = "Hello Struts!"; return "success"; } // get set method public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } }
<struts> <package name="siat" namespace="/" extends="struts-default"> <action name="helloAction" class="cn.ac.siat.helloaction.HelloAction" method="execute"> <result name="success">/index.jsp</result> </action> </package> </struts>
<body> ${message}<br><!--可以指定访问action里的数据--> </body>
上面通过<param>节点为action的savePath属性注入“/images”
原文地址:http://blog.csdn.net/cleverlzc/article/details/39339489