struts2 利用struts2-convention-plugin插件实现零配置
2015-03-27 16:39
323 查看
struts2使用convention-plugin插件可以减少,xml文件的配置。
确定搜索包的路径,只要是结尾为action的包都要搜索,并实例化
public class TestConventionAction extends ActionSupport {
private String newPath;
public String test(){
newPath = "/web/test.jsp";
return "dispatcher";
}
}TestConventionAction.java的test方法的 被映射成的访问方式是 test-convention!test.do
<!-- 设置各个ACTION默认继承哪个package --> <constant name="struts.convention.default.parent.package" value="base" /> <!--对指定包下面自动搜寻ACTION,并实例化 ,这里会搜索action包下的所有*Action类并实例化 --> <constant name="struts.convention.package.locators" value="action" /> <!--使用分隔符--> <constant name="struts.convention.action.name.separator" value="-" /> <package name="base" extends="convention-default"> <interceptors> <!--设置方法拦截器--> <interceptor name="actionInterceptor" class="com.myproject.platform.web.ActionMethodInterceptor"></interceptor> <interceptor-stack name="mystack"> <interceptor-ref name="actionInterceptor"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> </interceptor-stack> </interceptors> <default-interceptor-ref name="mystack"></default-interceptor-ref> <!--设置全局跳转--> <global-results> <result name="error">/web/system/error.jsp</result> <result name="login" type="redirect">/login.jsp</result> <!--跳转的Action中的属性,根据newPath的值进行跳转--> <result name="redirect" type="redirect">${newPath}</result> <result name="dispatcher" type="dispatcher">${newPath}</result> </global-results> </result> </package>
<constant name="struts.convention.package.locators" value="action" />
确定搜索包的路径,只要是结尾为action的包都要搜索,并实例化
public class TestConventionAction extends ActionSupport {
private String newPath;
public String test(){
newPath = "/web/test.jsp";
return "dispatcher";
}
}TestConventionAction.java的test方法的 被映射成的访问方式是 test-convention!test.do
相关文章推荐
- struts2插件convention-plugin实现零配置
- struts2采用convention-plugin实现零配置,Struts2 Convention插件的使用
- Struts2利用convention-plugin 实现零配置时Action与jsp的对应关系
- 使用struts2-convention-plugin-2.2.1.1.jar插件实现基于注解的配置。
- struts2采用convention-plugin实现零配置
- struts2 convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置(转自JavaEye)
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- Struts2.1.6以上,通过Annotation和struts2-convention-plugin.jar 实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- struts2采用convention-plugin实现零配置
- Struts2 采用convention-plugin实现零配置