随笔分类 -  Java(Struct)

摘要:Struts 2框架有两个核心配置文件,其中struts.xml文件主要负责管理应用中的Action映射,以及该Action包含的Result定义等。除此之 外,Struts 2框架还包含struts.properties文件,该文件定义了Struts 2框架的大量属性,开发者可以通过改变这些属性来... 阅读全文
posted @ 2015-01-13 17:21 sandea 阅读(203) 评论(0) 推荐(0) 编辑
摘要:struts2是可以配置默认的后缀名的,如http://localhost:8080/test.action,这个是默认的,但是也可以通过配置去修改这个.action为别的。这里是通过一个常量配置改变的。这样的就会变为http://localhost:8080/test.do来访问。但是我很不喜欢有... 阅读全文
posted @ 2015-01-09 15:46 sandea 阅读(796) 评论(0) 推荐(0) 编辑
摘要:from:http://www.cnblogs.com/huzx/archive/2011/06/09/2076328.html今天在做用户的登陆认证的时候出现的问题。在传参数的时候,发现参数丢失,导致页面出错 。 /admin/list.jsp 在网上找了一下,说struts... 阅读全文
posted @ 2014-07-15 09:59 sandea 阅读(199) 评论(0) 推荐(0) 编辑
摘要:一、配置:在struts2中配置常量的方式有三种:在struts.xml文件中配置在web.xml文件中配置在sturts.propreties文件中配置1.之所以使用struts.propreties文件配置,是因为为了保持与WebWork的向后兼容2.在实际开发中,在web.xml中配置常量相比... 阅读全文
posted @ 2014-06-18 23:31 sandea 阅读(321) 评论(0) 推荐(0) 编辑
摘要:版本:struts2.1.6此实例实现功能:用户需要指定用户名登陆,登陆成功进入相应页面执行操作,否则返回到登陆页面进行登陆,当直接访问操作页面(登陆后才能访问的页面)时则不允许,须返回登陆页面。代码如下:一、页面login.jsp yuewei'Login --> ... 阅读全文
posted @ 2014-05-26 22:30 sandea 阅读(313) 评论(0) 推荐(0) 编辑
摘要:首先定义我们自己的Interceptorpackage com.web.interceptor;import javax.servlet.http.HttpServletRequest;import org.apache.struts2.StrutsStatics;import org.apache... 阅读全文
posted @ 2014-05-26 22:25 sandea 阅读(371) 评论(0) 推荐(0) 编辑
摘要:Struts2的核心功能是action,对于开发人员来说,使用Struts2主要就是编写action,action类通常都要实现com.opensymphony.xwork2.Action接口,并实现该接口中的execute()方法。该方法如下:publicString execute()throw... 阅读全文
posted @ 2014-05-21 14:46 sandea 阅读(402) 评论(0) 推荐(0) 编辑
摘要:用了Convention插件来实现所谓的0配置,1.struts.convention.package.locators.basePackage=com.ZTest.web.action这个属性用于约定Action 类的根包(这个包是Java类的包,而不是Struts.xml中配置的节点)例如:在一... 阅读全文
posted @ 2014-05-21 09:21 sandea 阅读(537) 评论(0) 推荐(0) 编辑
摘要:1 因为struct2 如文件上传,数据验证等功能都是由系统默认的defalutStack中的拦截器实现的,所以我们定义拦截器需要引用系统默认的defalutStack这样才不会影响struct2在的其它功能struts.xml /WEB-INF/page/message.jsp //访问list_* 该方法时就会调用到PermissionInterceptor 这个拦截器PermissionInterceptor.javapublic String intercept(ActionInvocation invocation) throws Exception... 阅读全文
posted @ 2014-01-15 14:59 sandea 阅读(319) 评论(0) 推荐(0) 编辑
摘要:struts2之请求参数接收1. 采用基本类型接受请求参数(get/post)在Action类中定义与请求参数同名的属性,struts2便能自动接收请求参数并赋予给同名的属性。请求路径:http://localhost:8080/action/register.action?id=33publicclass HelloWorldAction {private Integer id;public Integer getId() {return id;}publicvoid setId(Integer id) {this.id = id;}} 2. 采用复合类型接受请求参数请求路径:http:/. 阅读全文
posted @ 2014-01-15 14:43 sandea 阅读(388) 评论(0) 推荐(0) 编辑
摘要:访问或添加request/session/application1 通过ActionContext//这样放置public String execute(){ ActionContext ctx = ActionContext.getContext(); ctx.getApplication().put("app","lll"); ctx.getSession().put("ses","session范围"); ctx.put("req", "request范围"); ret 阅读全文
posted @ 2014-01-15 14:39 sandea 阅读(183) 评论(0) 推荐(0) 编辑