新工作上班第九天了。写写自己的心得。
新工作第三天,分配了一个项目,一个开发组长,三个开发人员,一个月完成。开发人员:1. 苏:工作经验比我还多(10年),2. 曾:工作一年多。3.我。
第四天:讨论开发框架,论坛了苏从网站上自动生成代码的那一套。个人觉得不好用。开发组长周看起来像打酱油的,开发框架自己都没有,还要我们自己拿主意。
第五天:组长周给了一套他自己用过的开发代码,在resin上可以启动,但是只有源代码,没有用Eclipse搭起来的项目。苏和周一致说用任何编辑器写好代码以后,放到resin里面就跑。我觉得不可思议。(进入工作发现有太多不可思议了!)怎么可能不编译调试。我用Eclipse新建了一个项目,导入了周给的代码。项目能启动,就是首页地址有的请求路径不对。他的代码全是放到root下面的,而我新建的项目是在我的项目名称下面。
第二周,
周一:这个不太懂的周说:“你这还是适应不了这个开发环境,这样你今天还是不能做事!”我靠!经过研究,在tomcat里面改个配置即可
<Context path="" docBase="E:/code/apache-tomcat-6.0.39kaowu/webapps/eapp" debug="0" reloadable="true"/>
docBase路径不能有空格。
开始做登陆,沿用Apache shiro 的登陆 还比较顺利
周二,做表单录入,直接controller调用dao保存方法比较快。
(题外:他们也是用的springmvc hibernate 但是可以直接请求XX.jsp,跟我之前做过的项目完全不一样,为此研究了很久,发现他们的文件是放在webroot下面 不在web-inf目录下面。原来放在webroot下面是经过过滤器,但是不经过mvc 的控制器的。)
另外发现:在webroot下面时相对路径不好使,是不是要在web-inf下面才有用呢,未得验证。
周三,做列表。我原来用的页面前台都是easyui。这次的项目要兼容手机端,html5。于是美工妹子曾用了bootcss.(比我有见识,非常流行的前端有easyui,bootcss,ext js).
用bootstrap 表格的时候开始是客户端分页,在妹子的帮助下,找到了文档 http://bootstrap-table.wenzhixin.net.cn/examples/
找到了传到后台的每页条数Limit,和记录开始数Offset。
开始封装。分享一下我的代码。从bootstrap table 获取页码和页数,并交给后台处理。
$(‘#table‘).bootstrapTable({ url: ‘<%=path%>/FeedList.cqzk‘, striped: true, pagination: true, pageList: [3,5,20], pageSize:3, pageNumber:1, sidePagination:‘server‘,//设置为服务器端分页 columns: [{ field: ‘title‘, title: ‘标题‘ }, { field: ‘creatTime‘, title: ‘时间‘ } ] }); @RequestMapping(value = "/FeedList.cqzk") @ResponseBody public String url_ad1(HttpServletRequest request,BootPage page) throws ServletException,IOException,RuntimeException{ @SuppressWarnings("unchecked") // List<Feedback> list = feedBackDao.find("from Feedback"); BootPage pager = feedBackDao.getByPage("from Feedback",page,null); System.out.println((JSONArray.fromObject(pager)).getString(0).toString()); return (JSONArray.fromObject(pager)).getString(0).toString(); // 不写.getString(0) 就多一个中括号,返回的就是数组,写了就是返回第一个对象。 } public BootPage getByPage(String hql,BootPage pager,Map<String, Object> condition){ if (pager == null) { throw new IllegalArgumentException("分页 不能为空!"); } Query q = sessionFactory.getCurrentSession().createQuery(hql); q.setFirstResult(pager.getOffset()); q.setMaxResults(pager.getLimit()); if (condition != null) { q.setProperties(condition); } pager.setRows(q.list()); pager.setTotal(this.countAll(hql, condition)); return pager; } protected Long countAll(String hql, Map<String, Object> condition) { if (hql == null) { return 0l; } String tmpHql = hql.toLowerCase(); String regex = hql.substring(0, tmpHql.indexOf("from")); hql = hql.replaceFirst(regex, "select count(*) "); Query q = sessionFactory.getCurrentSession().createQuery(hql); if (condition != null) { q.setProperties(condition); } return (Long) q.uniqueResult(); } public final class BootPage<T> { protected Long total; protected List<T> rows; protected int limit=0; protected int offset = 0; protected String order ="asc" ;
原文:http://my.oschina.net/u/2340612/blog/394975