日期:2014-05-17 浏览次数:20872 次
package manning.chapterTwo; import org.apache.struts2.convention.annotation.Result; import com.opensymphony.xwork2.ActionSupport; @Result(name="success",location="login.jsp") public class AnnotationAction extends ActionSupport { /** * */ private static final long serialVersionUID = 2296720831644414741L; public String execute() { 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> <constant name="struts.devMode" value="true" /> <constant name="struts.i18n.encoding" value="UTF-8" /> <constant name="struts.custom.i18n.resources" value="messages" /> <!-- 配置默认的Action --> <package name="default" namespace="/" extends="struts-default"> <interceptors> <!-- 定义权限验证拦截器 --> <interceptor name="AuthInterceptor" class="cn.jbit.votingsystem.interceptor.AuthInterceptor"/> <!-- 自定义连接器栈--> <interceptor-stack name="myStack"> <interceptor-ref name="defaultStack"/> <interceptor-ref name="AuthInterceptor"/> </interceptor-stack> </interceptors> <!-- 使用拦截器栈 --> <default-interceptor-ref name="myStack"/> <global-results> <result name="error" >/WEB-INF/page/error.jsp</result> <result name="login">/WEB-INF/page/login.jsp</result> </global-results> </package> </struts>
------解决方案--------------------
你的ACTION访问路径错了,应该是
http://127.0.0.1:8888/Struts/annotation.action
约定的规则是:如果是已Action结尾要去掉Action,以大小写为单词分隔,以“-”符号分割。
我的项目里有个ACTION的命名是WsThreadInfoAction,访问它的链接就是ws-thread-info.action