上一页 1 2 3 4 5 6 7 ··· 21 下一页
摘要: 首先自定义拦截器需要实现Interceptor接口package control.center;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionInvocation;import com.opensymphony.xwork2.interceptor.Interceptor;public class PersonAction implements Interceptor {@Overridepublic void destroy() {}@Overridepublic void 阅读全文
posted @ 2011-02-26 14:39 魔战 阅读(403) 评论(0) 推荐(0)
摘要: 向response,request,application中放入属性public String execute() throws Exception{ ActionContext atx=ActionContext.getContext();atx.getApplication().put("app", "应用范围");//往application里放入数据atx.getSession().put("ses","session范围");//往session里放入数据atx.put("req",& 阅读全文
posted @ 2011-02-24 13:37 魔战 阅读(395) 评论(0) 推荐(0)
摘要: struts2里面不使用ActionForm来接收参数,而是在Action中定义一个与请求参数同名的属性就能接收到表单中的参数。jsp页面上通过el表达式来取得Action中属性的值。如果在一个类中包含了另一个类作为参数,那么在form表单中定义属性名称的时候就需要使用对象来指定了,比如form中的input的name为Person.id,在el中也要使用Person.id获取数据。struts2中有两种类型转换器:1,局部类型转换器:定义类型转换器:package control.center;import java.sql.Date;import java.text.ParseExcept 阅读全文
posted @ 2011-02-23 23:54 魔战 阅读(193) 评论(0) 推荐(0)
摘要: 用户请求后,filter拦截请求,匹配请求然后经过struts2的拦截器,在进入action,在Action中处理,然后返回return result返回。struts1与struts2的不同:struts2为用户的每一次请求都会创建一个Action,所以struts2中的Action是线程安全;struts1的Action创建之后放在了缓存中,一直存在,只有一个实例。为了避免struts.xml文件过于大而臃肿,可以将一个struts.xml配置文件分解成多个配置文件,然后再struts.xml文件中包含其他配置文件。<include file="struts-user.xm 阅读全文
posted @ 2011-02-23 22:19 魔战 阅读(280) 评论(0) 推荐(0)
摘要: 类:package control.center;import java.net.URLEncoder;public class HelloWordAction {private String savePath;public String getSavePath() {return savePath;}public void setSavePath(String savePath) {this.savePath = savePath;}public String execute() throws Exception{URLEncoder.encode("星期三"," 阅读全文
posted @ 2011-02-23 21:48 魔战 阅读(440) 评论(0) 推荐(0)
摘要: struts2在webwork2基础发展而来,struts2与struts1相比,没有跟ServletAPI和struts API有着紧密的耦合,struts2为无侵入式设计,而struts1却属于侵入式设计;struts2提供了拦截器,利用拦截器可以进行AOP编程,实现如权限拦截等功能;struts2提供了类型转换器,struts1的数据类型转换是通过BeanUtil来实现的。struts2在StrutsPrepareAndExcuteFilter的init()方法中将读取类路径下默认的配置文件struts.xml完成初始化操作,读取struts.xml的内容后,以javabean形式存放在 阅读全文
posted @ 2011-02-23 21:03 魔战 阅读(477) 评论(0) 推荐(0)
摘要: getCurrentSession()与openSession()的区别:1,采用getCurrentSession()创建的session会绑定到当前线程中,而采用openSession()创建的session则不会,2,采用getCurrentSession()创建的session在session执行commit或rollback时会自动关闭,openSession()需要手动关闭使用getCurrentSession()方法需要在hibernate配置文件中指定如果使用的是本地事务(jdbc事务):<property name="hibernate.current_ses 阅读全文
posted @ 2011-02-22 22:10 魔战 阅读(247) 评论(0) 推荐(0)
摘要: 接口:package com.jzq.spring;public interface UserManager {public void addUser(String username,String password);public void deleteUser(int id);public void modifyUser(int id,String username,String password);public String findUserById(int id);}实现类:package com.jzq.spring;public class UserManagerImpl imple 阅读全文
posted @ 2011-02-22 21:09 魔战 阅读(5427) 评论(0) 推荐(0)
摘要: 接口:package com.jzq.spring;public interface UserManager {public void addUser(String username,String password);public void deleteUser(int id);public void modifyUser(int id,String username,String password);public String findUserById(int id);}实现:package com.jzq.spring;public class UserManagerImpl implem 阅读全文
posted @ 2011-02-22 20:45 魔战 阅读(232) 评论(0) 推荐(0)
摘要: spring对AOP的支持(采用Annotation的方式)支持库:/lib/aspectj/aspectjrt.jar和aspectjweaver.jarUserManagerImpl类:package com.jzq.spring;public class UserManagerImpl implements UserManager {@Overridepublic void addUser(String username, String password) { System.out.println("------UserManagerImpl.addUser()-----&qu 阅读全文
posted @ 2011-02-22 20:10 魔战 阅读(236) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 ··· 21 下一页