随笔分类 -  Struts2

摘要:1. 让所有的标签,不再显示label<constant name="struts.ui.theme" value="simple" />2. 页面编码格式定义(可解决中文乱码问题)<constant name="struts.i18n.encoding" value="gbk" />3. 上传附件定义<constant name="struts.multipart.parser" value="jakarta">constant</ 阅读全文
posted @ 2012-09-25 10:02 Enix 阅读(196) 评论(0) 推荐(0)
摘要:在开发过程中,struts.xml的配置过于复杂重复,所以想到了用通配符"*"。而url里面包含多个层级的话,又需要分开定义不同的包。所以想能不能在action的名称中加入斜杠。在google上查了一下资料,发现可行。http://struts.apache.org/2.1.8/docs/wildcard-mappings.html<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundat 阅读全文
posted @ 2012-09-24 17:50 Enix 阅读(1857) 评论(1) 推荐(1)
摘要:在日常的WEB应用开发过程中,前端常会涉及AJAX,而前台与后台的交互常用的数据格式就是JSON。Struts2中使用JSON的方法方法如下:Action:如果action中的某些属性不需要在json里面出现,可以通过annotation :@JSON(serialize=false)来标记改属性不需返回至JSON。注意,如果某属性没有get方法,则该属性亦不会在返回JSON串里面出现。import java.util.List;import org.apache.struts2.json.annotations.JSON;import com.opensymphony.xwork2.Acti 阅读全文
posted @ 2012-09-19 11:24 Enix 阅读(1186) 评论(0) 推荐(0)
摘要:在日常的开发过程中,我们时常需要在做某个Action操作前,验证用户是否已登录,若用户尚未登录,则跳转至登录页面;若已登录,则获取当前的用户信息,并进行下一步的操作。Struts2访问Session获取用户信息,我们自然想到了Session。而在Struts2中访问Session可以通过两种途径:1. 通过ActionContext中的getSession方法来回获取Session存储对象import java.util.Map; import org.apache.struts2.interceptor.SessionAware; import com.opensymphony.xwork2 阅读全文
posted @ 2012-09-15 17:15 Enix 阅读(9006) 评论(2) 推荐(1)
摘要:Struts2的处理结果标签是告诉系统下一步是要做什么。处理结果是通过标签<result></result>来实现的。在讲述struts2的处理结果前,先讲述一下forward和redirect存在着什么区别。Forward 和 Redirect的区别简单的说Forward是发生在服务器内部,客户端不知道发生了request的转向。客户A向服务器B请求,服务器B处理完请求并发生forward转向,请求不会经过客户端,而是在内部请求另外一个服务器资源。对于客户A来说,该操作是透明的。Redirect则是客户端A向B请求后,服务器B处理完请求结果,并把结果返回值客户端A,并 阅读全文
posted @ 2012-09-14 17:10 Enix 阅读(2457) 评论(0) 推荐(0)
摘要:From now on, I will write a blog to show you the integration of Struts2 + Hibernate3 + Spring to develop a CURD application. I am a beginer of SSH framework, so these series blogs may got some mistakes. Please feel free to discuss with me through blog reply.This is the final souce category of my CUR 阅读全文
posted @ 2012-08-17 15:00 Enix 阅读(423) 评论(0) 推荐(0)