Chinaunix首页 | 论坛 | 博客
  • 博客访问: 951302
  • 博文数量: 168
  • 博客积分: 3853
  • 博客等级: 中校
  • 技术积分: 1854
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-15 23:50
文章分类

全部博文(168)

文章存档

2014年(12)

2013年(46)

2012年(60)

2011年(11)

2010年(1)

2009年(17)

2008年(21)

我的朋友

分类: Java

2014-03-04 10:40:10

项目中之前只有一个默认的struts.convention.default.parent.package   默认加载的Package管理
1、在默认的package中配置一些拦截器和处理,例如权限验证之类。
2、权限验证只想对一部分Action来配置,那就配置多个Package在Struts.xml中;但是在配置中struts.convention.default.parent.package只能接受一个package,如何加载其他的Package呢
3、
从网上搜索资料没有这方面的记载。
4、官方文档中有提了这么一段话:

The ParentPackage annotation allows applications to define different parent Struts package for specific action classes or Java packages. Here is an example of using the annotation on an action class:

com.example.actions.HelloWorld
package com.example.actions; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.ParentPackage;

@ParentPackage("customXWorkPackage") public class HelloWorld extends ActionSupport { public String execute() { return SUCCESS;
  }
}

To apply this annotation to all actions in a package (and subpackages), add it to package-info.java. An alternative to this annotation is to set struts.convention.default.parent.package in XML.



5、根据4中描述的,在需要特殊处理的action中加入
ParentPackage   这个特殊注解便可以解决



阅读(2125) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~