package com.zsq.action;
import javax.servlet.http.HttpServletRequest;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorldAction extends ActionSupport {
private HttpServletRequest request;
public String add() {
request.setAttribute("path", "update");
return "add";
}
public String update() {
return "update";
}
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println("执行action");
return SUCCESS;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="defult" namespace="/" extends="struts-default">
<default-action-ref name="index"></default-action-ref>
<action name="index">
<result>/error.jsp</result>
</action>
<action name="*_*" method="{2}" class="com.zsq.action.{1}Action">
<result>/result.jsp</result>
<result name="add">
<param name="location">/${#request.path}.jsp</param>
</result>
<result name="update">/{2}.jsp</result>
<result name="error">/error.jsp</result>
</action>
<action name="LoginAction" method="login" class="com.zsq.action.LoginAction">
<result>/success.jsp</result>
<result name="input">/login.jsp</result>
</action>
</package>
</struts>