struts.xml
<struts>
<include file="GoogleSuggest.xml" />
<include file="login.xml"></include>
<include file="book.xml"></include>
<include file="upload.xml"></include>
<package name="struts2" namespace="/" extends="struts-default">
<global-results>
<result name="index">/index.jsp</result>
</global-results>
<default-action-ref name="index" />
<action name="index" class="org.lzstone.index.action.IndexAction">
<result name="success">/index.jsp</result>
</action>
</package>
</struts>
IDE报错,发现将<global-results>放置到<default-action-ref name="index" />之下错误消失,发现default的优先级别还是很高的。
写了一个简单拦截器
public class LoginInterceptor implements Interceptor{
@Override
public void destroy() {
System.out.println("最终离开Interceptor");
}
@Override
public void init() {
System.out.println("开始进入Interceptor");
}
@Override
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext act = invocation.getInvocationContext();
Map session = act.getSession();
Object object = session.get("user");
if(null != object){
return invocation.invoke();
}
return "index";
}
}
失败返回index,拦截器注册在
<struts>
<package name="login" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="loginInterceptor"
class="org.lzstone.interceptor.LoginInterceptor" />
</interceptors>
<action name="login" class="org.lzstone.login.action.LoginAction">
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
<interceptor-ref name="defaultStack" />
<interceptor-ref name="loginInterceptor" />
</action>
</package>
</struts>
测试的时候发现无法发现index,global-results下面我已经有index
后再在login.xml下面加入
<global-results>
<result name="index">/index.jsp</result>
</global-results>
运行成功
结果发现struts2中的package限制还是很大的,global-results也只是存在一个包的全局
分享到:
相关推荐
struts-config.xml struts标准配置文件 struts-config
Struts2配置文件详解--精品版这个很好很强大
struts2-core-2.0.1.jar, struts2-core-2.0.11.1.jar, struts2-core-2.0.11.2.jar, struts2-core-2.0.11.jar, struts2-core-2.0.12.jar, struts2-core-2.0.14.jar, struts2-core-2.0.5.jar, struts2-core-2.0.6.jar,...
struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置文件以及代码示例struts2配置...
struts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jarstruts2-spring-plugin-2.3.15.2.jar ; struts2-json-plugin-2.3.16.3.jar
书写struts.xml时候使eclipse拥有代码提示功能必要的DTD文件struts-2.3.dtd及Key
最新struts2-struts1-plugin-2.1.8.1.jar
赠送Maven依赖信息文件:struts2-json-plugin-2.3.24.pom; 包含翻译后的API文档:struts2-json-plugin-2.3.24-javadoc-API文档-中文(简体)版.zip; Maven坐标:org.apache.struts:struts2-json-plugin:2.3.24; ...
struts2-convention-plugin-2.3.32
struts2-config-browser-plugin-2.3.24.jar, struts2-core-2.3.24.jar, struts2-jasperreports-plugin-2.3.24.jar, struts2-jfreechart-plugin-2.3.24.jar, struts2-pell-multipart-plugin-2.3.24.jar, struts2-...
struts2 最新漏洞 S2-016、S2-017修补方案 .docx
struts2-ssl-plugin-1.2.1.jar
struts2-dojo-plugin-2.3.4 jar 日期控件的jar包 需要的自行下载
struts2-dojo-plugin-2.2.1.jar, 直接导入到Struts2项目里即可,注意版本。
K8_Struts2_EXP S2-045 & 任意文件上传 20170310,无密码,2017版,最新版
struts2-文件上传
·Struts2配置文件介绍 struts.xml action package ·Struts2配置文件介绍 struts.xml action package
struts2-struts1-plugin-2.1.6.jar
struts2-convention-plugin-2.3.15.1.jar
JavaEE源代码 struts2-spring-plugin-2.0.11JavaEE源代码 struts2-spring-plugin-2.0.11JavaEE源代码 struts2-spring-plugin-2.0.11JavaEE源代码 struts2-spring-plugin-2.0.11JavaEE源代码 struts2-spring-plugin-...