这种东西,网上一堆
http://blog.csdn.net/arielxp/archive/2004/06/27/27913.aspx
http://blog.csdn.net/arielxp/archive/2004/06/27/27913.aspx
解决方案 »
- java属性copy BeanUtils.copyProperties(to, from)问题
- hibernate 没有作关联,如何处理多表查询(可怕的表设计)
- tomcat 配置出错,大家帮我看看这个出错信息。
- SSH事务配置问题,高手给我点指点
- 关于两个服务器的集成问题(jboss)!
- 有没有关于Hibernaet的帮助文档啊?
- 想找一个java程序员一起北京租房
- Struts是什么?
- 音像店管理系统100%struts编写
- 在hibernate中,用Middlegen-Hibernate来实现对数据库中表的映射的问题???
- Eclipse+Jboss开发中的问题,急!!!!!
- 一个日期问题,请大家帮忙指点
dbListAction.java文件: 在<分页></分页>之间的代码是实现数据库分页显示的代码。。(省略)public final class dbListAction extends Action { // 变量定义: private Log log = LogFactory.getLog("org.apache.struts.webapp.Example"); private ConnectionPool pool; public dbListAction() { pool = ConnectionPool.getInstance(); } //函数定义: public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes and parameters we will need Locale locale = getLocale(request); MessageResources messages = getResources(request); HttpSession session = request.getSession(); dbListForm m_dbListForm = (dbListForm) form; Connection con = null; try { con = pool.getConnection(); dbListDAO m_dbListDAO = new dbListDAO(con); //定义DAO对象,用于实现数据库的各种操作 String action=request.getParameter("action"); //动作类型 String search=request.getParameter("search"); //数据库查找方式 String expression=request.getParameter("expression"); //参数,这里用于保存记录(行)的ID数据 if(action==null)action="find"; if(search==null)search="UNsearch"; if(expression==null)expression=""; expression=toChinese(expression); //处理中文问题,实现编码转换 if("delete".equals(action)) //删除记录操作 { m_dbListDAO.removeID(expression); } //////////// if("update".equals(action)||"insert".equals(action)) //更新、添加记录操作 { dbList m_dbList= new dbList(); //<update> m_dbList.set序号(m_dbListForm.get序号()); m_dbList.set姓名(m_dbListForm.get姓名()); m_dbList.set备注(m_dbListForm.get备注()); //</update> if("update".equals(action)) //调用DAO对象更新记录 m_dbListDAO.update(m_dbList,expression); if("insert".equals(action)) //调用DAO对象添加记录 m_dbListDAO.create(m_dbList); } ///////////////查找数据库 //<sqlstr> String sql="SELECT * FROM dbo.Test"; //</sqlstr> ////SQL字符处理 if("search".equals(search)) { //<search> sql+=" where "; sql+="序号"; sql+="="; if("NULL".equals(expression)||"".equals(expression)) { sql+=m_dbListForm .get序号(); } else { sql+=expression; } sql+=""; //</search> } //<分页> m_dbListDAO.setLength(10);//设置每页显示记录数 int ipage;//当前页 try { String page=request.getParameter("page");//分页参数,读取请求的当前页 ipage=java.lang.Integer.parseInt(page,10); } catch (Exception e) { ipage=m_dbListForm.getPage(); } if(ipage<1)ipage=1; Collection col = m_dbListDAO.findSQL(sql,ipage);//通过DAO对象查询数据 request.setAttribute("dbList",col); //保存数据 String pagestr=m_dbListDAO.getPagestr(ipage);//分页字符串,分页内容 String s_find,str; if(!"search".equals(search)) //查找和全部显示两个不同的操作,其分页字符串不同,在此进行处理。如果是全部显示则去掉"search=search&" { s_find="search=search&"; while(pagestr.indexOf(s_find)!=-1) { str=pagestr.substring(0,pagestr.indexOf(s_find)); str+=pagestr.substring(pagestr.indexOf(s_find)+s_find.length(),pagestr.length()); pagestr=str; } } m_dbListForm.setPagestr(pagestr); m_dbListForm.setAction(action); request.setAttribute("dbListForm",m_dbListForm); //</分页> return mapping.findForward("success"); } catch (SQLException e) { e.printStackTrace(); throw new RuntimeException("Unable to get connection."); } finally { try { if (con != null) con.close(); } catch (SQLException e) { throw new RuntimeException(e.getMessage()); } } } public String toChinese(String ss) { //处理中文问题,实现编码转换 if (ss != null) { try { String temp_p = ss; byte[] temp_t = temp_p.getBytes("ISO8859-1"); ss = new String(temp_t); } catch (Exception e) { System.err.println("toChinese exception:" + e.getMessage()); System.err.println("The String is:" + ss); } } return ss; } }
看不清楚.能不能直接发到我的邮箱里啊?
最好是源文件,,能看到效果的