摘要: 有四种方法可以得到request session application等web元素。方法一LoginAction1.javaView Code public class LoginAction1 extends ActionSupport { private Map request; private Map session; private Map application; public LoginAction1() { request = (Map)ActionContext.getContext().get("request"); ... 阅读全文
posted @ 2012-02-22 23:13 濤叔 阅读(320) 评论(0) 推荐(1) 编辑
摘要: UserAction.javaView Code public class UserAction extends ActionSupport { private String name; public String add() { if(name == null || !name.equals("admin")) { this.addFieldError("name", "name is error"); this.addFieldError("name", "name is too long" 阅读全文
posted @ 2012-02-22 15:20 濤叔 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 在struts.xml中配置字符处理。struts.xmlView Code <struts> <constant name="struts.i18n.encoding" value="GBK" /> <!-- internationalization --> </package></struts>即可转换字符编码。但是在struts2.1.6中存在BUG。需要在WEB.XML重新配置以个过滤器,换成2.0的配置。或则手动配置filter,还可以用spring的filter。View Code 阅读全文
posted @ 2012-02-22 13:54 濤叔 阅读(168) 评论(0) 推荐(0) 编辑
摘要: UserAction.javaView Code import com.bjsxt.struts2.user.model.User;import com.opensymphony.xwork2.ActionSupport;import com.opensymphony.xwork2.ModelDriven;public class UserAction extends ActionSupport implements ModelDriven<User>{ private User user = new User(); public String add() { ... 阅读全文
posted @ 2012-02-22 13:31 濤叔 阅读(240) 评论(0) 推荐(0) 编辑
摘要: DomaimModel域模型 就是将参数封装成 dto 对象。struts.xmlView Code <struts> <constant name="struts.devMode" value="true" /> <package name="user" extends="struts-default" namespace="/user"> <action name="user" class="com.bjsxt.stru 阅读全文
posted @ 2012-02-22 11:29 濤叔 阅读(496) 评论(0) 推荐(0) 编辑
摘要: struts.xmlView Code <struts> <constant name="struts.devMode" value="true" /> <package name="user" extends="struts-default" namespace="/user"> <action name="user" class="com.bjsxt.struts2.user.action.UserAction" 阅读全文
posted @ 2012-02-22 11:14 濤叔 阅读(321) 评论(0) 推荐(0) 编辑