- 浏览: 325344 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (254)
- java (178)
- tomcat (6)
- 邮件 (1)
- smtp (1)
- Linux (2)
- 编码 (2)
- 导入工程 (1)
- Specification Level (1)
- hibernate (10)
- 字段类型 (1)
- 字段类型匹配 (1)
- 数据库 (3)
- sql (9)
- struts2 (8)
- 类型转换 (2)
- java,MyEclipse,SVN (1)
- Myecplise (4)
- 输入校验 (1)
- JFrame (2)
- Oracle (8)
- google (1)
- Swing (3)
- Fusioncharts (1)
- 找工作 (0)
- js (4)
- jsp (11)
- displaytag (1)
- spring (8)
- 工作 (1)
- String (1)
- 算法 (2)
- IO (1)
- xml (3)
- 设计模式 (1)
- UML (1)
- 文档 (1)
- ajax (1)
- 日常 (7)
- sql server (1)
- mysql (3)
- git (1)
- Maven (1)
- mongodb (1)
- postman (1)
最新评论
分页逻辑的封装处理(请参考AbstractManager.java)
ThreadLocal设计模式,线程局部变量,因为每一次请求都对应一个线程,把初始化的分页数据放在这个局部变量中
当用到时,直接从当前线程中获取。原理同HibernateOpenSessionInView.
为避免在Action(呈现层)和Manager(业务逻辑层)之间传递大量的参数,
可以使用ThreadLocal模式来传递分页参数(包括:offset和pagesize)。
-定义:参考SystemContext.java
-往ThreadLocal中赋值:参考PagerFilter.java
-从ThreadLocal中获取分页参数:参考AbstractManager.java
-------------------------------------------------------------
具体代码如下:
1.定义分页数据封装类
package com.feihu.oa.page;
import java.util.List;
public class PagerModel
{
private List datas; // 分页数据列表
private int total; // 查询总记录数
public List getDatas()
{
return datas;
}
public void setDatas(List datas)
{
this.datas = datas;
}
public int getTotal()
{
return total;
}
public void setTotal(int total)
{
this.total = total;
}
}
2.使用ThreadLocal存储分页起始索引记录位置 与 分页页面显示的记录数
package com.feihu.oa.page;
public class SystemContext {
private static ThreadLocal offset = new ThreadLocal(); //记录起始索引位置
private static ThreadLocal pagesize = new ThreadLocal(); //每页显示多少条记录
public static void setOffset(int _offset){
offset.set(_offset);
}
public static int getOffset(){
Integer _offset = (Integer)offset.get();
if(_offset == null){
return 0;
}
return _offset;
}
public static void removeOffset(){
offset.remove();
}
public static void setPagesize(int _pagesize){
pagesize.set(_pagesize);
}
public static int getPagesize(){
Integer _pagesize = (Integer)pagesize.get();
if(_pagesize == null){
return Integer.MAX_VALUE;
}
return _pagesize;
}
public static void removePagesize(){
pagesize.remove();
}
}
3.定义分页逻辑处理封装类AbstractManager.java
--------------------------------------------------------------------------
package com.feihu.dao;
import java.util.List;
import org.hibernate.Query;
import com.feihu.oa.manager.SystemException;
import com.feihu.oa.page.PagerModel;
import com.feihu.oa.page.SystemContext;
public abstract class AbstractManager extends MyDaoSupport
{
public PagerModel searchPaginated(String hql){
return searchPaginated(hql, null);
}
public PagerModel searchPaginated(String hql,Object value){
return searchPaginated(hql, new Object[]{value});
}
public PagerModel searchPaginated(String hql,Object[] values){
return searchPaginated(hql, values, SystemContext.getOffset(), SystemContext.getPagesize());
}
public PagerModel searchPaginated(String hql,int offset,int pagesize){
return searchPaginated(hql, null, offset, pagesize);
}
public PagerModel searchPaginated(String hql,Object value,int offset,int pagesize){
return searchPaginated(hql, new Object[]{value}, offset, pagesize);
}
public PagerModel searchPaginated(String hql,Object[] values,int offset,int pagesize)
{
String countHql = getCountQuery(hql);//使用传递进来的hql语句 构造出查询总记录数的语句
Query query = getSession().createQuery(countHql);//创建hql查询语句,获取总记录数,要用session,getHibernateTemplate没有此方法
if(values != null && values.length > 0)
{
for(int i = 0; i<values.length;i++)
{
query.setParameter(i, values[i]);
}
}
int total = ((Long)query.uniqueResult()).intValue(); //返回结果只有一个时可用此方法
query = getSession().createQuery(hql);//创建查询语句以获取数据集合
query.setFirstResult(offset); //设置hibernate查询开始索引
query.setMaxResults(pagesize); //设置hibernate查询多少条记录
List datas = query.list(); //得到查询数据结果列表集合
PagerModel pm = new PagerModel();
pm.setDatas(datas); //将结果集合设置进 封装好的 分页类
pm.setTotal(total); //将总记录数设置进 分页类
return pm;
}
//
//
private String getCountQuery(String hql)
{
int index = hql.indexOf("from");
if(index!=-1)
{
return "select count(*) " + hql.substring(index);//hql语句中,只有查询总记录数才能用select count(*)这样的写法
}
throw new SystemException("无效的HQL查询语句【"+hql+"】","exception.hql.query");
}
}
++++++++++++++++++++++++++++++++++++
涉及到的其他类如下:
++++++++++++++++++++++++++++++++++++
package com.feihu.dao;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public abstract class MyDaoSupport extends HibernateDaoSupport
{
private SessionFactory mySessionFacotry;
@Resource
public void setMySessionFacotry(SessionFactory sessionFacotry) {
this.mySessionFacotry = sessionFacotry;
}
@PostConstruct
public void injectSessionFactory() {
super.setSessionFactory(mySessionFacotry);
}
}
+++++++++++++++++++++++++++++++
异常信息自定义类
package com.feihu.oa.manager;
public class SystemException extends RuntimeException
{
//异常代码关键字,其值在MessageResources.properties文件定义
String key;
//可以输出一些异常时的参数
Object[] values;
public String getKey()
{
return key;
}
public SystemException(String message,String key)
{
super(message);
this.key=key;
// TODO Auto-generated constructor stub
}
public SystemException()
{
super();
// TODO Auto-generated constructor stub
}
public SystemException(String message, Throwable cause)
{
super(message, cause);
// TODO Auto-generated constructor stub
}
public SystemException(String message)
{
super(message);
// TODO Auto-generated constructor stub
}
public Object[] getValues()
{
return values;
}
public SystemException(Throwable cause)
{
super(cause);
// TODO Auto-generated constructor stub
}
public SystemException(String message,String key,Object[] values)
{
super(message);
this.key = key;
this.values = new Object[]{values};
// TODO Auto-generated constructor stub
}
public SystemException(String message,String key,Object value)
{
super(message);
this.key = key;
this.values = new Object[]{value};
// TODO Auto-generated constructor stub
}
}
++++++++++++++++++++++++++++++++++++++++++
异常信息处理类
package com.feihu.oa.web.action;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;
import com.feihu.oa.manager.SystemException;
public class SystemExceptionHandler extends ExceptionHandler
{
@Override
public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException
{
ActionForward forward = null;
if(ae.getPath() != null)
{
forward = new ActionForward(ae.getPath());
}else
{
forward = mapping.getInputForward();
}
if (ex instanceof SystemException)
{
SystemException sysex = (SystemException) ex;
String key = sysex.getKey();
ActionMessage error = null;
if(key==null)
{
error= new ActionMessage(sysex.getKey(),sysex.getMessage());
}else if(sysex.getValues()!=null)
{
error=new ActionMessage(key,sysex.getValues());
}
this.storeException(request, key, error, forward, ae.getScope());
}
return super.execute(ex, ae, mapping, formInstance, request, response);
}
}
++++++++++++++++++++++++++++++++++++++++++
struts-config.xml文件配置
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="orgform"
type="com.feihu.oa.web.formbean.OrgForm">
</form-bean>
</form-beans>
<global-exceptions>
<exception key="errors.detail"
type="com.feihu.oa.manager.SystemException"
path="/common/exception.jsp" scope="request"
handler="com.feihu.oa.web.action.SystemExceptionHandler" />
</global-exceptions>
<action-mappings>
<action path="/org" parameter="method" name="orgform">
<!-- struts异常自动处理 -->
<!-- <exception key="errors.detail" type="java.lang.RuntimeException" path="/common/exception.jsp" scope="request"/>
-->
<!-- 自定义异常 -->
<forward name="index" path="/org/index.jsp"></forward>
<forward name="add_input" path="/org/add_input.jsp"></forward>
<forward name="add_success"
path="/common/pub_add_success.jsp">
</forward>
<forward name="del_success"
path="/common/pub_del_success.jsp">
</forward>
<!-- forward name="exception" path="/common/exception.jsp"></forward>-->
</action>
</action-mappings>
<controller><!-- spring提供的,用于管理 structs请求的action,控制器根据当前的action的path寻找bean,用bean对应的action处理请求 -->
<set-property property="processorClass"
value="org.springframework.web.struts.DelegatingRequestProcessor" />
</controller><!--配置spring控制器-->
<!-- 使用异常机制时要定义这个资源树文件 -->
<message-resources parameter="MessageResources"></message-resources>
</struts-config>
-------------------------------------------------------------------------------
4.定义PagerFilter过滤类,从TreadLocal中获取并设置初始化分页参数
package com.feihu.web.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import com.feihu.oa.page.SystemContext;
public class PagerFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest)request;
SystemContext.setOffset(getOffset(httpRequest));
SystemContext.setPagesize(getPagesize(httpRequest));
try{
chain.doFilter(request, response);
}finally{
SystemContext.removeOffset();
SystemContext.removePagesize();
}
}
private int getOffset(HttpServletRequest request){
int offset = 0;
try {
offset = Integer.parseInt(request.getParameter("pager.offset"));
} catch (Exception ignore) {
}
return offset;
}
private int getPagesize(HttpServletRequest request){
return 10;
}
public void init(FilterConfig arg0) throws ServletException {
}
}
-----------------------------------------------------------------------------
5.配置web.xml文件,将过滤类加入到web.xml文件中
<filter>
<filter-name>PagerFilter</filter-name>
<filter-class>com.feihu.web.filter.PagerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PagerFilter</filter-name>
<url-pattern>
@Override
protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
OrgForm formbean = (OrgForm)form;
Integer parentId = formbean.getParentId();
request.setAttribute("orgs", orgManager.searchOrgs(parentId));
int ppid=0;
if(formbean.getParentId()!=null && formbean.getParentId()>0)
{
Organization org = orgManager.findOrg(formbean.getParentId());
Organization parent = org.getParent();
if(parent!=null)
{
ppid = parent.getId();
}
}
request.setAttribute("ppid", ppid);
return mapping.findForward("index");
}
public ActionForward addInput(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
return mapping.findForward("add_input");
}
public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
OrgForm formbean = (OrgForm)form;
Integer parentId=formbean.getParentId();
Organization org = new Organization();
BeanUtils.copyProperties(org, formbean);
return mapping.findForward("add_success");
}
public ActionForward del(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
OrgForm formbean = (OrgForm)form;
return mapping.findForward("del_success");
}
}
ThreadLocal设计模式,线程局部变量,因为每一次请求都对应一个线程,把初始化的分页数据放在这个局部变量中
当用到时,直接从当前线程中获取。原理同HibernateOpenSessionInView.
为避免在Action(呈现层)和Manager(业务逻辑层)之间传递大量的参数,
可以使用ThreadLocal模式来传递分页参数(包括:offset和pagesize)。
-定义:参考SystemContext.java
-往ThreadLocal中赋值:参考PagerFilter.java
-从ThreadLocal中获取分页参数:参考AbstractManager.java
-------------------------------------------------------------
具体代码如下:
1.定义分页数据封装类
package com.feihu.oa.page;
import java.util.List;
public class PagerModel
{
private List datas; // 分页数据列表
private int total; // 查询总记录数
public List getDatas()
{
return datas;
}
public void setDatas(List datas)
{
this.datas = datas;
}
public int getTotal()
{
return total;
}
public void setTotal(int total)
{
this.total = total;
}
}
2.使用ThreadLocal存储分页起始索引记录位置 与 分页页面显示的记录数
package com.feihu.oa.page;
public class SystemContext {
private static ThreadLocal offset = new ThreadLocal(); //记录起始索引位置
private static ThreadLocal pagesize = new ThreadLocal(); //每页显示多少条记录
public static void setOffset(int _offset){
offset.set(_offset);
}
public static int getOffset(){
Integer _offset = (Integer)offset.get();
if(_offset == null){
return 0;
}
return _offset;
}
public static void removeOffset(){
offset.remove();
}
public static void setPagesize(int _pagesize){
pagesize.set(_pagesize);
}
public static int getPagesize(){
Integer _pagesize = (Integer)pagesize.get();
if(_pagesize == null){
return Integer.MAX_VALUE;
}
return _pagesize;
}
public static void removePagesize(){
pagesize.remove();
}
}
3.定义分页逻辑处理封装类AbstractManager.java
--------------------------------------------------------------------------
package com.feihu.dao;
import java.util.List;
import org.hibernate.Query;
import com.feihu.oa.manager.SystemException;
import com.feihu.oa.page.PagerModel;
import com.feihu.oa.page.SystemContext;
public abstract class AbstractManager extends MyDaoSupport
{
public PagerModel searchPaginated(String hql){
return searchPaginated(hql, null);
}
public PagerModel searchPaginated(String hql,Object value){
return searchPaginated(hql, new Object[]{value});
}
public PagerModel searchPaginated(String hql,Object[] values){
return searchPaginated(hql, values, SystemContext.getOffset(), SystemContext.getPagesize());
}
public PagerModel searchPaginated(String hql,int offset,int pagesize){
return searchPaginated(hql, null, offset, pagesize);
}
public PagerModel searchPaginated(String hql,Object value,int offset,int pagesize){
return searchPaginated(hql, new Object[]{value}, offset, pagesize);
}
public PagerModel searchPaginated(String hql,Object[] values,int offset,int pagesize)
{
String countHql = getCountQuery(hql);//使用传递进来的hql语句 构造出查询总记录数的语句
Query query = getSession().createQuery(countHql);//创建hql查询语句,获取总记录数,要用session,getHibernateTemplate没有此方法
if(values != null && values.length > 0)
{
for(int i = 0; i<values.length;i++)
{
query.setParameter(i, values[i]);
}
}
int total = ((Long)query.uniqueResult()).intValue(); //返回结果只有一个时可用此方法
query = getSession().createQuery(hql);//创建查询语句以获取数据集合
query.setFirstResult(offset); //设置hibernate查询开始索引
query.setMaxResults(pagesize); //设置hibernate查询多少条记录
List datas = query.list(); //得到查询数据结果列表集合
PagerModel pm = new PagerModel();
pm.setDatas(datas); //将结果集合设置进 封装好的 分页类
pm.setTotal(total); //将总记录数设置进 分页类
return pm;
}
//
//
private String getCountQuery(String hql)
{
int index = hql.indexOf("from");
if(index!=-1)
{
return "select count(*) " + hql.substring(index);//hql语句中,只有查询总记录数才能用select count(*)这样的写法
}
throw new SystemException("无效的HQL查询语句【"+hql+"】","exception.hql.query");
}
}
++++++++++++++++++++++++++++++++++++
涉及到的其他类如下:
++++++++++++++++++++++++++++++++++++
package com.feihu.dao;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public abstract class MyDaoSupport extends HibernateDaoSupport
{
private SessionFactory mySessionFacotry;
@Resource
public void setMySessionFacotry(SessionFactory sessionFacotry) {
this.mySessionFacotry = sessionFacotry;
}
@PostConstruct
public void injectSessionFactory() {
super.setSessionFactory(mySessionFacotry);
}
}
+++++++++++++++++++++++++++++++
异常信息自定义类
package com.feihu.oa.manager;
public class SystemException extends RuntimeException
{
//异常代码关键字,其值在MessageResources.properties文件定义
String key;
//可以输出一些异常时的参数
Object[] values;
public String getKey()
{
return key;
}
public SystemException(String message,String key)
{
super(message);
this.key=key;
// TODO Auto-generated constructor stub
}
public SystemException()
{
super();
// TODO Auto-generated constructor stub
}
public SystemException(String message, Throwable cause)
{
super(message, cause);
// TODO Auto-generated constructor stub
}
public SystemException(String message)
{
super(message);
// TODO Auto-generated constructor stub
}
public Object[] getValues()
{
return values;
}
public SystemException(Throwable cause)
{
super(cause);
// TODO Auto-generated constructor stub
}
public SystemException(String message,String key,Object[] values)
{
super(message);
this.key = key;
this.values = new Object[]{values};
// TODO Auto-generated constructor stub
}
public SystemException(String message,String key,Object value)
{
super(message);
this.key = key;
this.values = new Object[]{value};
// TODO Auto-generated constructor stub
}
}
++++++++++++++++++++++++++++++++++++++++++
异常信息处理类
package com.feihu.oa.web.action;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ExceptionHandler;
import org.apache.struts.config.ExceptionConfig;
import com.feihu.oa.manager.SystemException;
public class SystemExceptionHandler extends ExceptionHandler
{
@Override
public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException
{
ActionForward forward = null;
if(ae.getPath() != null)
{
forward = new ActionForward(ae.getPath());
}else
{
forward = mapping.getInputForward();
}
if (ex instanceof SystemException)
{
SystemException sysex = (SystemException) ex;
String key = sysex.getKey();
ActionMessage error = null;
if(key==null)
{
error= new ActionMessage(sysex.getKey(),sysex.getMessage());
}else if(sysex.getValues()!=null)
{
error=new ActionMessage(key,sysex.getValues());
}
this.storeException(request, key, error, forward, ae.getScope());
}
return super.execute(ex, ae, mapping, formInstance, request, response);
}
}
++++++++++++++++++++++++++++++++++++++++++
struts-config.xml文件配置
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans>
<form-bean name="orgform"
type="com.feihu.oa.web.formbean.OrgForm">
</form-bean>
</form-beans>
<global-exceptions>
<exception key="errors.detail"
type="com.feihu.oa.manager.SystemException"
path="/common/exception.jsp" scope="request"
handler="com.feihu.oa.web.action.SystemExceptionHandler" />
</global-exceptions>
<action-mappings>
<action path="/org" parameter="method" name="orgform">
<!-- struts异常自动处理 -->
<!-- <exception key="errors.detail" type="java.lang.RuntimeException" path="/common/exception.jsp" scope="request"/>
-->
<!-- 自定义异常 -->
<forward name="index" path="/org/index.jsp"></forward>
<forward name="add_input" path="/org/add_input.jsp"></forward>
<forward name="add_success"
path="/common/pub_add_success.jsp">
</forward>
<forward name="del_success"
path="/common/pub_del_success.jsp">
</forward>
<!-- forward name="exception" path="/common/exception.jsp"></forward>-->
</action>
</action-mappings>
<controller><!-- spring提供的,用于管理 structs请求的action,控制器根据当前的action的path寻找bean,用bean对应的action处理请求 -->
<set-property property="processorClass"
value="org.springframework.web.struts.DelegatingRequestProcessor" />
</controller><!--配置spring控制器-->
<!-- 使用异常机制时要定义这个资源树文件 -->
<message-resources parameter="MessageResources"></message-resources>
</struts-config>
-------------------------------------------------------------------------------
4.定义PagerFilter过滤类,从TreadLocal中获取并设置初始化分页参数
package com.feihu.web.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import com.feihu.oa.page.SystemContext;
public class PagerFilter implements Filter {
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest)request;
SystemContext.setOffset(getOffset(httpRequest));
SystemContext.setPagesize(getPagesize(httpRequest));
try{
chain.doFilter(request, response);
}finally{
SystemContext.removeOffset();
SystemContext.removePagesize();
}
}
private int getOffset(HttpServletRequest request){
int offset = 0;
try {
offset = Integer.parseInt(request.getParameter("pager.offset"));
} catch (Exception ignore) {
}
return offset;
}
private int getPagesize(HttpServletRequest request){
return 10;
}
public void init(FilterConfig arg0) throws ServletException {
}
}
-----------------------------------------------------------------------------
5.配置web.xml文件,将过滤类加入到web.xml文件中
<filter>
<filter-name>PagerFilter</filter-name>
<filter-class>com.feihu.web.filter.PagerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PagerFilter</filter-name>
<url-pattern>
@Override
protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
OrgForm formbean = (OrgForm)form;
Integer parentId = formbean.getParentId();
request.setAttribute("orgs", orgManager.searchOrgs(parentId));
int ppid=0;
if(formbean.getParentId()!=null && formbean.getParentId()>0)
{
Organization org = orgManager.findOrg(formbean.getParentId());
Organization parent = org.getParent();
if(parent!=null)
{
ppid = parent.getId();
}
}
request.setAttribute("ppid", ppid);
return mapping.findForward("index");
}
public ActionForward addInput(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
return mapping.findForward("add_input");
}
public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
OrgForm formbean = (OrgForm)form;
Integer parentId=formbean.getParentId();
Organization org = new Organization();
BeanUtils.copyProperties(org, formbean);
return mapping.findForward("add_success");
}
public ActionForward del(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
{
OrgForm formbean = (OrgForm)form;
return mapping.findForward("del_success");
}
}
发表评论
-
领域精通涉及技术点(不分先后)
2017-12-20 19:35 624Java8 netty jvm kafaka消息队列 上传下载 ... -
计算机各种单位讲解及换算
2017-12-13 13:54 1645我还听过有UK的 一、最小单位:位(bit,缩写为b) 在原 ... -
JAVA字符串格式化-String.format()和MessageFormat的使用
2017-12-05 10:39 1454String.format()常规类型的格式化 Stri ... -
eclipse启动项目常见问题
2017-11-16 17:46 1189今儿遇到了个问题,ecli ... -
字符编码笔记:ASCII,Unicode和UTF-8
2017-10-23 16:37 461讲的太牛逼了: http://ww ... -
emoji简单讲解
2017-10-23 15:17 979emoji处理方式大起底 http://blog.csdn.n ... -
BigDecimal讲解
2017-10-12 15:58 448BigDecimal 由任意精度的整数非标度值 和 32 位的 ... -
eclips 控制台console上不打印信息
2017-09-06 21:53 5841、进windows菜单 -> show view -& ... -
详解RequestMappingHandlerMapping和RequestMappingHandlerAdapter
2017-08-29 17:08 2990http://donald-draper.iteye.com/ ... -
用@ExceptionHandler 来进行切面异常处理
2017-08-29 11:47 2319有时候我们想处理某个类里Controller中抛出的异常怎么搞 ... -
Spring 注解@Component、@Repository、@Service、@Controller区别
2017-08-28 15:27 1021spring 2.5 中除了提供 @Com ... -
线程的一点小总结
2017-08-23 20:36 710java中main方法启动的是一个进程还是一个线程? 答:是一 ... -
线程池
2017-08-23 17:35 526诸如Web 服务器、数据库 ... -
Class源码大概讲解
2017-08-23 16:47 519http://blog.csdn.net/a327369238 ... -
Spring 事务相关
2017-08-14 12:10 477Transactionz注解的readOnly ... -
把时间当做朋友-前言
2017-08-13 20:47 411要管理的不是时间,而是自己。人们生活在同一个世界,却又各自 ... -
单例里面的方法讲解
2017-08-11 14:55 492spring里的controller是单例的。系统针对每个co ... -
eclipse拷贝出来的项目名称还是原来的
2017-07-26 16:46 1084需要修改的有如下几个地方: 1、pom.xml里面打包的名字一 ... -
自定义hibernate方言,新增自定义函数
2017-06-27 10:47 884按位与运算(&)在许多数据库中都是支持的,遗憾的是,H ... -
http请求参数:header body paramter三种参数区别、联系
2017-06-19 10:46 489512345
相关推荐
这使得分页样式易于调整,同时也使分页逻辑与服务器端的分页处理逻辑分离,保持了良好的代码结构。 2. **使用步骤**: - 首先,需要将`pager-taglib.jar`包添加到项目的类路径中。 - 接着,在JSP页面中使用`...
通过创建一个通用的`Pager`类,我们可以方便地在项目中复用分页逻辑。结合`ThreadLocal`来存储公用参数,可以简化查询方法的接口。最后,在JSP页面上,使用EL和JSTL标签展示分页链接,为用户提供友好的导航体验。...
- DRP系统中,他负责DAO模式及工厂模式的设计,分页组件封装,流向单维护,会计核算期间维护和物料维护,这揭示了他在数据库操作和业务逻辑处理上的专业水平。 6. **技术栈**: - 从简历中可以看出,该工程师熟练...
但Hitis,直接返回给你实际执行的sql和paramters数组,你想封装分页,还不是轻而易举的事 (6)在ibatis中,也许你看不懂其代码,看不懂其设置模式,但Hitis,会让你看的很轻松,很明白,你想怎么改,就怎么改... (7)...
Servlet 在 MVC 模式中通常作为**Controller**角色出现,负责接收用户请求、处理业务逻辑并决定显示哪些视图。 #### 6. Servlet 的生命周期 Servlet 的生命周期主要包括以下几个阶段: - **加载和实例化**:当...
- 或使用WITH子句配合RANK()函数实现更复杂的分页逻辑。 ##### Oracle的基本数据类型 - **NUMBER**:数值类型。 - **VARCHAR2**:可变长度字符串。 - **DATE**:日期类型。 - **TIMESTAMP**:精确到毫秒的时间戳。...
- **DAO (Data Access Object)**:封装对数据源访问的细节。 #### 第六层:算法招式辨析 **1. 递归算法** - **递归**:函数直接或间接地调用自身。 **2. 贪婪算法** - **贪婪算法**:在每一步选择中都采取最好...
它将请求与处理逻辑解耦,并且易于与其他Spring组件集成。 **问题二:SpringMVC的流程?** 1. 用户发送请求至前端控制器DispatcherServlet。 2. DispatcherServlet收到请求后调用HandlerMapping处理器映射器。 3. ...
1. Java:异常处理、面向对象特性(封装、继承、多态)、集合框架(ArrayList、LinkedList、HashMap等)、并发编程(synchronized、volatile、ThreadLocal等)。 2. C/C++:指针、内存管理、预处理、模板、STL容器、...
{1.8.2}逻辑运算}{29}{subsection.1.8.2} {1.8.3}条件运算符}{29}{subsection.1.8.3} {1.8.4}移位运算符}{30}{subsection.1.8.4} {1.9}流程控制}{31}{section.1.9} {1.9.1}\texttt {if\ldots esle\ldots }}{31}...