网页地址 http://blog.csdn.net/lpy3654321/article/details/31841573

项目设想,在项目开发中,我们的开发者大多数时间都在反复开发 相同的keyword,相同的语法. 但就在这种情况下还会常常发生语法的错误,并且每一个开发者的代码风格不同. 其它人员阅读困难.新人的学习成本也会添加.

这些问题会浪费非常多时间,也会影响到开发者的心情,和程序质量. 由这些问题我想的解决方法是 <代码生成工具> . 代码生成能够解决上述问题,加强约定. 对于普通CRUD的开发效率能够提升50%以上,错误率差点儿为0 , 是项目系统的开发利器.

代码生成 代码生成工具

自己写的开发平台ssmy_m 与代码生成 ,struts2 mybatis spring maven jquery jqgrid jqueryui

有问题请留言,或QQ110146324

最以下有生成出来的代码

SVN上的代码基础功能已经都有了.美工没弄,有须要的自己改吧.

在/ssmy_m/src/main/webapp/common/include_com.jsp里引用.否则代码生成会有影响

DEMO:

 SSMy主页  http://liupengyuan.xicp.cn
 ssmy开发框架SSMy  http://liupengyuan.xicp.cn/ssmy_m/
 ssmy框架的代码生成工具  http://liupengyuan.xicp.cn/generate_m/
 generate_m生成的代码演示样例  http://download.csdn.net/detail/lpy3654321/8438605
  • 开发平台

svn: https://m2.svnspot.com/lpy3654321.ssmy_m/

帐号:guest112233

password:guest112233

也能够到 http://code.svnspot.com 注冊

开发平台页面 :右键新窗体打开图片能够放大

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbHB5MzY1NDMyMQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">

最以下有生成出来的代码




  • 代码生成

svn: https://m2.svnspot.com/lpy3654321.ssmy_generate_m/

帐号:guest112233

password:guest112233

也能够到 http://code.svnspot.com 注冊

通过过数据库表生成BEAN  action servce dao xml js jsp

改动dbConfigs.xml文件,可配置生成的数据库(启动改动也能够,不须要重新启动)

http://127.0.0.1:8080/generate_m

下载zip后,解压,复制SRC 然后直接粘贴到myeclipse 项目里

<?xml version="1.0" encoding="UTF-8"?>
<!-- 用于生成数据库的配置文件 -->
<dbConfigs> <dbConfig id="localMysql"><!-- 配置名称 -->
<url>jdbc:mysql://localhost:3306/ssmy</url><!-- url -->
<username>root</username><!-- </username> -->
<password>root</password><!-- password -->
<driverClass>com.mysql.jdbc.Driver</driverClass><!-- driverClass -->
</dbConfig> <dbConfig id="localOracle">
<url>jdbc:oracle:thin:@localhost:1521:orcl</url>
<username>ssmy</username>
<password>ssmy</password>
<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
</dbConfig> <dbConfig id="dsd_zjk">
<url>jdbc:oracle:thin:@192.168.3.34:1521:orcl</url>
<username>dsd_zjk</username>
<password>dsd_zjk</password>
<driverClass>oracle.jdbc.driver.OracleDriver</driverClass>
</dbConfig> </dbConfigs>

代码生成页面:右键新窗体打开图片能够放大



"项目基本WEB层命名空间"  和  "模块WEB层命名空间"   这两个input会决定Struts2的命名空间和JS的引用路径

<struts>
<package name="com.liupengyuan.framework.pageView.action.PageViewAction" extends="struts-default" namespace="/framework/pageView"> <action name="pageView_*"
class="pageViewAction"
method="{1}">
</action> <action name="pageView">
<result>/framework/pageView/pageView.jsp</result>
</action> </package>
</struts>
  • 代码文件夹:

  • Zip包文件夹:

  • HTML JS 代码
pageView.jsp:
<%@ page language="java" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>记录网络訪问量</title>
<%@ include file="/common/include_com.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="${pageContext.request.contextPath}/jsp/moduleWeb/pageView/js/pageView.js"></script>
<!--<script src="js/pageView.js"></script>--> </head>
<body> <div class="ui-layout-north">
<div class="navbar"><font size="2" > 当前操作:记录网络訪问量</font></div>
</div> <div class="ui-layout-center">
<!-- <div class="title_level1">查询</div> -->
<div class="formarea">
<form id="pageViewSearchForm">
<fieldset>
<legend style="margin-left: 10px;">查询</legend> <table>
<tr>
<td style="width:150px;" align="right" ><label for="requestIp">用户IP:</label></td>
<td>
<div class="input">
<input type="text" name="requestIp" size="40" />
</div>
</td>
<td style="width:150px;" align="right" ><label for="session">记录会话ID:</label></td>
<td>
<div class="input">
<input type="text" name="session" size="40" />
</div>
</td>
</tr>
<tr>
<td style="width:150px;" align="right" ><label for="module">訪问的模块:</label></td>
<td>
<div class="input">
<input type="text" name="module" size="40" />
</div>
</td>
<td style="width:150px;" align="right" ><label for="visitTime">訪问时间:</label></td>
<td>
<div class="input">
<input type="text" name="visitTime" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" size="40" />
</div>
</td>
</tr>
<tr>
<td style="width:150px;" align="right" ><label for="visitCount">訪问数量:</label></td>
<td>
<div class="input">
<input type="text" name="visitCount" size="40" />
</div>
</td>
</tr>
</table>
</fieldset>
</form>
<div class="buttons">
<button id="searchB">查询</button>
<button id="resetB">清空</button>
</div>
</div>
<div class="toolbar">
<button id="addB">添加</button>
<button id="editB">改动</button>
<button id="deleteB">删除</button>
</div>
<table id="pageViewTable"></table>
</div>
<div id="pageViewAddOrEditForm">
<div class="formarea">
<form id="pageViewForm" type="ajax"> <input type="hidden" id="id" name="id"/>
<table>
<tr>
<td style="width:70px;" align="right" ><label for="requestIp">用户IP:</label></td>
<td>
<div class="input">
<input type="text" id="requestIp" name="requestIp" class="validate[maxSize[50] ] " size="40" />
</div>
</td>
</tr>
<tr>
<td style="width:70px;" align="right" ><label for="session">记录会话ID:</label></td>
<td>
<div class="input">
<input type="text" id="session" name="session" class="validate[maxSize[100] ] " size="40" />
</div>
</td>
</tr>
<tr>
<td style="width:70px;" align="right" ><label for="module">訪问的模块:</label></td>
<td>
<div class="input">
<input type="text" id="module" name="module" class="validate[maxSize[100] ] " size="40" />
</div>
</td>
</tr>
<tr>
<td style="width:70px;" align="right" ><label for="visitTime">訪问时间:</label></td>
<td>
<div class="input">
<input type="text" id="visitTime" name="visitTime" class="Wdate " onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" size="40" />
</div>
</td>
</tr>
<tr>
<td style="width:70px;" align="right" ><label for="visitCount">訪问数量:</label></td>
<td>
<div class="input">
<input type="text" id="visitCount" name="visitCount" class="validate[maxSize[10] ] " size="40" />
</div>
</td>
</tr>
</table> </form>
</div>
</div>
</body>
</html>


pageView.js:

$(function() {
jQuery("#pageViewTable").initGrid({
url : templateRoot+"/jsp/moduleWeb/pageView/pageView_pagelist.do",
height: 480,
//colNames:[ "id" , "用户IP" , "记录会话ID" , "訪问的模块" , "訪问时间" , "訪问数量" ], //假设colNames存在 则忽略colModel内的colName.
colModel : [
{ colName : "id", name : "id", hidden : true, id : true, key:true, index : "id", width : 120, align:"cente" } ,
{ colName : "用户IP", name : "requestIp", hidden : false, id : false, key:false, index : "request_ip",width : 120, align:"cente" } ,
{ colName : "记录会话ID",name : "session", hidden : false, id : false, key:false, index : "session", width : 120, align:"cente" } ,
{ colName : "訪问的模块",name : "module", hidden : false, id : false, key:false, index : "module", width : 120, align:"cente" } ,
{ colName : "訪问时间", name : "visitTime", hidden : false, id : false, key:false, index : "visit_time", width : 120, align:"cente" } ,
{ colName : "訪问数量", name : "visitCount",hidden : false, id : false, key:false, index : "visit_count", width : 120, align:"cente" }
]
}); $("#pageViewAddOrEditForm").initDialog({
width : 580,
height: 220,
buttons : { // 为对话框加入按钮
"保存" : function() {
pageViewSave();
},
"取消" : function() {
$("#pageViewAddOrEditForm").dialog("close");
}
}
}); $("#addB").click(function() {
addDialog();
});
$("#editB").click(function() {
updateDialog();
});
$("#deleteB").click(function() {
deleteByids();
});
$("#searchB").click(function() {
search();
});
$("#resetB").click(function() {
$("#pageViewSearchForm").clearForm();
}); function addDialog() {
$("#pageViewForm").clearForm();
$("#pageViewAddOrEditForm")
.dialog("option", "title", "加入记录网络訪问量窗体")
.dialog("open");
} function updateDialog() {
var pageViewGrid = $("#pageViewTable");
if (!pageViewGrid.ifGridSelectedOne()) {
alert("请选择一条记录!");
return false;
}
$("#pageViewForm").clearForm();
$("#pageViewAddOrEditForm")
.dialog("option", "title", "改动记录网络訪问量窗体")
.dialog("open");
// var rowData = pageViewGrid.getSelectedRows()[0];
// $("#pageViewForm").loadValues(rowData);
var ids = pageViewGrid.getSelectedIds();
$("#pageViewForm").loadForm(templateRoot + "/jsp/moduleWeb/pageView/pageView_load.do",{id : ids[0]});
} function deleteByids() {
var pageViewGrid = $("#pageViewTable");
if(!pageViewGrid.ifGridSelected()){
alert('请选择要删除的记录!');
return false;
}
var ids = pageViewGrid.getSelectedIds();
if(confirm("确定要删除 "+ ids.length+" 条数据吗?")){
var ids = pageViewGrid.getSelectedIds();
$.ajax({
url : templateRoot + "/jsp/moduleWeb/pageView/pageView_delete.do",
data : {"ids" : ids},
type : "post", dataType : "json", cache : false, traditional :true,
success : function(responseText, statusText, xhr, $form) {
alert(responseText.message || "保存成功!");
if(responseText.success){
$("#pageViewTable").reloadGrid();
$("#gridDialog").dialog("close");
}
}
});
};
} function pageViewSave() {
$("#pageViewForm").submitForm({
url : templateRoot + "/jsp/moduleWeb/pageView/pageView_save.do",
success:function(responseText, statusText, xhr, $form){
alert(responseText.message || "保存成功!");
if(responseText.success){
$("#pageViewTable").reloadGrid();
$("#pageViewAddOrEditForm").dialog("close");
}
},
failure:function(data, options){
alert(responseText.message || "保存失败!");
}
});
} function search(){
var params = $("#pageViewSearchForm").formToObject();
$("#pageViewTable").searchGrid(params);
} function searchByParam(params){
$("#pageViewTable").searchGrid(params);
}
});

  • Java代码

action:PageViewAction.java

package com.liupengyuan.test.modulePage.pageView.action;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.liupengyuan.framework.util.JSONOuter;
import com.liupengyuan.framework.web.query.IGenericPage;
import com.liupengyuan.framework.web.struts2.BaseAction;
import com.liupengyuan.test.modulePage.pageView.model.PageView;
import com.liupengyuan.test.modulePage.pageView.service.PageViewService; /**
* @ClassName PageViewAction
* @Description 记录网络訪问量Action
* @struts2配置文件名称 struts-test-modulePage-pageView.xml
* @spring3配置文件名称 spring-test-modulePage-pageView.xml
* @mybatis3配置文件名称 mybatis-test-modulePage-pageView.xml
* @表名 sys_page_view
* @author generate
* @date - 2015-02-10 15:33:10
* @version V1.0
*/ @SuppressWarnings("serial")
@Controller("pageViewAction")
@Scope("prototype")
public class PageViewAction extends BaseAction<PageView> {
@Autowired
private PageViewService pageViewService; private PageView pageView; private String[] ids; /**
* 新增或者改动记录
*/
public void save() {
pageViewService.saveOrUpdate(pageView);
JSONOuter.writeBeanMsg(getPrintWriter(), pageView,"数据保存成功");
} /**
* 载入数据对象
*/
public void load() {
PageView pageViewObj = pageViewService.getById( pageView.getId() );
JSONOuter.writeBeanMsg(getPrintWriter(), pageViewObj);
} /**
* 分页查询
*/
public void pagelist() {
IGenericPage<PageView> iPage = pageViewService.findPageBy(
pageView,
this.getPage(),
this.getRows(),
this.getSidx(),
this.getSord());
JSONOuter.writePage(getPrintWriter(), iPage);
} /**
* 数据列表
*/
public void list() {
List<PageView> list = pageViewService.findListBy(
pageView, this.getSidx(), this.getSord());
JSONOuter.writeList(getPrintWriter(), list);
} /**
* 批量删除记录
*/
public void delete() {
String msg = "";
if(ids!=null && ids.length>0){
int s = pageViewService.deleteByIds(ids);
msg = "成功删除 " + s + " 条记录!!!";
}else{
msg = "删除失败,请选择要删除的记录!!!";
}
JSONOuter.writeSuccessMsg(getPrintWriter(), msg);
} /**
* 模型驱动。自己主动装配页面属性
*/
public PageView getModel() {
pageView = new PageView();
return pageView;
} public void setIds(String[] ids) {
this.ids = ids;
}
}

service接口:PageViewService.java

package com.liupengyuan.test.modulePage.pageView.service;

import java.util.List;

import com.liupengyuan.test.modulePage.pageView.model.PageView;
import com.liupengyuan.framework.web.query.IGenericPage; /**
* @ClassName PageViewService
* @Description 记录网络訪问量服务接口
* @struts2 配置文件名称 struts-test-modulePage-pageView.xml
* @spring3 配置文件名称 spring-test-modulePage-pageView.xml
* @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
* @表名 sys_page_view
* @author generate
* @date - 2015-02-10 15:33:10
* @version V1.0
*/
public interface PageViewService {
/**
* 依据通过主键ID获取一个记录网络訪问量实例
* @param id 记录网络訪问量ID
* @return 记录网络訪问量实例
*/ public PageView getById(java.io.Serializable id); /**
* 批量删除
* @param ids 要删除的记录网络訪问量ID集合
* @return 删除成功的记录生活
*/
public Integer deleteByIds(java.io.Serializable[] ids);
public Integer deleteById(java.io.Serializable ids); /**
* 保持一个新增的记录网络訪问量实例
* @param pageView 记录网络訪问量
*/
public void save(PageView pageView); /**
* 保存一个改动的记录网络訪问量实例
* @param pageView 记录网络訪问量
*/
public void update(PageView pageView); /**
* 保存一个新增或改动的记录网络訪问量实例
* @param pageView 记录网络訪问量
*/
public void saveOrUpdate(PageView pageView); /**
* 分页查询
* @param param 查询參数
* @param currentPage 当前页码
* @param rows 每页记录行数
* @param sort 排序字段
* @param dir 排序方式、降序(desc)或升序(asc)
* @return 记录网络訪问量实例集合
*/
public IGenericPage<PageView> findPageBy(
PageView param,
int currentPage,
int rows,
String sort,
String dir); /**
* 主要是配合分页查询返回总记录数
* @param param 主要查询參数封装在param中
* @return 记录数
*/
public Integer getCountByParam(PageView param); /**
* 不分页查询
* @param param 主要查询參数封装在param中
* @param sort 排序字段
* @param dir 排序方式、降序(desc)或升序(asc)
* @return 记录网络訪问量实例集合
*/
public List<PageView> findListBy(PageView param, String sort, String dir); }

service实现类:PageViewServiceImpl.java

package com.liupengyuan.test.modulePage.pageView.service.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import com.liupengyuan.framework.web.query.IGenericPage; import com.liupengyuan.test.modulePage.pageView.dao.PageViewDao;
import com.liupengyuan.test.modulePage.pageView.model.PageView;
import com.liupengyuan.test.modulePage.pageView.service.PageViewService; /**
* @ClassName PageViewServiceImpl
* @Description 记录网络訪问量服务实现类
* @struts2 配置文件名称 struts-test-modulePage-pageView.xml
* @spring3 配置文件名称 spring-test-modulePage-pageView.xml
* @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
* @表名 sys_page_view
* @author generate
* @date - 2015-02-10 15:33:10
* @version V1.0
*/ @Service("pageViewService")
public class PageViewServiceImpl implements PageViewService {
@Autowired
private PageViewDao pageViewDao; /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#getById(java.io.Serializable)
*/
public PageView getById(java.io.Serializable id) {
return pageViewDao.getById(id);
} /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#deleteByIds(java.io.Serializable[])
*/
public Integer deleteByIds(java.io.Serializable[] ids) {
return pageViewDao.deleteByIds(ids); } /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#deleteById(java.io.Serializable)
*/
public Integer deleteById(java.io.Serializable id) {
return pageViewDao.deleteById(id);
} /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#save(com.liupengyuan.test.modulePage.pageView.model.PageView)
*/
public void save(PageView ob) {
pageViewDao.save(ob);
} /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#update(com.liupengyuan.test.modulePage.pageView.model.PageView)
*/
public void update(PageView ob) {
pageViewDao.update(ob);
} /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#saveOrUpdate(com.liupengyuan.test.modulePage.pageView.model.PageView)
*/
public void saveOrUpdate(PageView ob) {
if (ob != null) {
// 假设ID不为空说明是改动的实例,为更新操作
if (null != ob.getId() && StringUtils.isNotEmpty(String.valueOf(ob.getId()))) {
pageViewDao.update(ob);
} else {
pageViewDao.save(ob);
}
}
} /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#findPageBy(com.liupengyuan.test.modulePage.pageView.model.PageView, int, int, java.lang.String, java.lang.String)
*/
public IGenericPage<PageView> findPageBy(
PageView param,
int currentPage,
int rows,
String sort,
String dir) {
return pageViewDao.findPageBy(
wrapParams(param), currentPage, rows, sort, dir);
} /*
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#getCountByParam(com.liupengyuan.test.modulePage.pageView.model.PageView)
*/
public Integer getCountByParam(PageView param) {
return pageViewDao.getCountBy(wrapParams(param));
} /**
* (non-Javadoc)
* @see com.liupengyuan.test.modulePage.pageView.service.PageViewService#findListBy(com.liupengyuan.test.modulePage.pageView.PageView, java.lang.String, java.lang.String)
*/
public List<PageView> findListBy(
PageView param,
String sort,
String dir) {
return pageViewDao.findListBy(
wrapParams(param), sort, dir);
} /**
* 为模糊查询前后加装%%
*/
private PageView wrapParams(PageView param) {
if(param != null){
if(StringUtils.isNotEmpty(param.getRequestIp())){
param.setRequestIp("%"+param.getRequestIp()+"%");
}
if(StringUtils.isNotEmpty(param.getSession())){
param.setSession("%"+param.getSession()+"%");
}
if(StringUtils.isNotEmpty(param.getModule())){
param.setModule("%"+param.getModule()+"%");
}
}
return param;
}
}

DAO接口:PageViewDao.java

package com.liupengyuan.test.modulePage.pageView.dao;

import com.liupengyuan.framework.dao.IBaseGenericDAO;
import com.liupengyuan.test.modulePage.pageView.model.PageView; /**
* @ClassName PageViewDao
* @Description 记录网络訪问量DAO接口
* @struts2 配置文件名称 struts-test-modulePage-pageView.xml
* @spring3 配置文件名称 spring-test-modulePage-pageView.xml
* @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
* @表名 sys_page_view
* @author generate
* @date - 2015-02-10 15:33:10
* @version V1.0
*/
public interface PageViewDao extends IBaseGenericDAO<PageView> { }

DAO实现类:PageViewDaoImpl.java

package com.liupengyuan.test.modulePage.pageView.dao.impl;

import org.springframework.stereotype.Repository;
import com.liupengyuan.framework.dao.MybatisBaseGenericDAOImpl;
import com.liupengyuan.framework.util.GeneratorKey;
import com.liupengyuan.test.modulePage.pageView.dao.PageViewDao;
import com.liupengyuan.test.modulePage.pageView.model.PageView; /**
* @ClassName PageViewDaoImpl
* @Description 记录网络訪问量DAO实现类
* @struts2 配置文件名称 struts-test-modulePage-pageView.xml
* @spring3 配置文件名称 spring-test-modulePage-pageView.xml
* @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
* @表名 sys_page_view
* @author generate
* @date - 2015-02-10 15:33:10
* @version V1.0
*/
@Repository("pageViewDao")
public class PageViewDaoImpl
extends MybatisBaseGenericDAOImpl<PageView>
implements PageViewDao {
/**
* 生成UUID主键值。
* @param ob 记录网络訪问量
*/
public void generateId(PageView ob) {
//id
if(null == ob.getId() || ob.getId().length() == 0){
ob.setId(GeneratorKey.genaraId());
}
}
}

model:PageView.java

package com.liupengyuan.test.modulePage.pageView.model;

/**
* @ClassName PageView
* @Description 记录网络訪问量 实体(领域)对象
* @struts2 配置文件名称 struts-test-modulePage-pageView.xml
* @spring3 配置文件名称 spring-test-modulePage-pageView.xml
* @mybatis3 配置文件名称 mybatis-test-modulePage-pageView.xml
* @表名 sys_page_view
* @author generate
* @date - 2015-02-10 15:33:10
* @version V1.0
*/
public class PageView implements java.io.Serializable { /** id */
private java.lang.String id; /**
* 获取id
* @return id
*/
public java.lang.String getId() {
return this.id;
}
/**
* 设置id
*/
public void setId(java.lang.String id){
this.id = id;
} /** 用户IP */
private java.lang.String requestIp; /**
* 获取用户IP
* @return 用户IP
*/
public java.lang.String getRequestIp() {
return this.requestIp;
}
/**
* 设置用户IP
*/
public void setRequestIp(java.lang.String requestIp){
this.requestIp = requestIp;
} /** 记录会话ID */
private java.lang.String session; /**
* 获取记录会话ID
* @return 记录会话ID
*/
public java.lang.String getSession() {
return this.session;
}
/**
* 设置记录会话ID
*/
public void setSession(java.lang.String session){
this.session = session;
} /** 訪问的模块 */
private java.lang.String module; /**
* 获取訪问的模块
* @return 訪问的模块
*/
public java.lang.String getModule() {
return this.module;
}
/**
* 设置訪问的模块
*/
public void setModule(java.lang.String module){
this.module = module;
} /** 訪问时间 */
private java.util.Date visitTime; /**
* 获取訪问时间
* @return 訪问时间
*/
public java.util.Date getVisitTime() {
return this.visitTime;
}
/**
* 设置訪问时间
*/
public void setVisitTime(java.util.Date visitTime){
this.visitTime = visitTime;
} /** 訪问数量 */
private java.lang.Integer visitCount; /**
* 获取訪问数量
* @return 訪问数量
*/
public java.lang.Integer getVisitCount() {
return this.visitCount;
}
/**
* 设置訪问数量
*/
public void setVisitCount(java.lang.Integer visitCount){
this.visitCount = visitCount;
}
}
  • XML 配置文件

mybatis文件:mybatis-test-modulePage-pageView.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liupengyuan.test.modulePage.pageView.model.PageView">
<resultMap id="pageViewResultMap" type="com.liupengyuan.test.modulePage.pageView.model.PageView">
<!-- id -->
<result column="id" property="id" jdbcType="VARCHAR" />
<!-- 用户IP -->
<result column="request_ip" property="requestIp" jdbcType="VARCHAR" />
<!-- 记录会话ID -->
<result column="session" property="session" jdbcType="VARCHAR" />
<!-- 訪问的模块 -->
<result column="module" property="module" jdbcType="VARCHAR" />
<!-- 訪问时间 -->
<result column="visit_time" property="visitTime" jdbcType="TIMESTAMP" />
<!-- 訪问数量 -->
<result column="visit_count" property="visitCount" jdbcType="INTEGER" />
</resultMap>
<!-- 表名 -->
<sql id="tableNameSql">
sys_page_view
</sql> <!-- 用于select查询、insert的公用抽取的列 -->
<sql id="commonSelectColumnsPrefix">
id ,
request_ip ,
session ,
module ,
visit_time ,
visit_count
</sql> <!-- 按主键查找条件语句 -->
<sql id="conditionOnlyId">
id = #{id}
</sql> <sql id="mainSql">
SELECT
<include refid="commonSelectColumnsPrefix"/>
FROM
<include refid="tableNameSql"/> p
</sql> <sql id="varSql">
<where>
<if test="requestIp!=null and requestIp!=''">and p.request_ip like #{requestIp} </if>
<if test="session!=null and session!=''">and p.session like #{session} </if>
<if test="module!=null and module!=''">and p.module like #{module} </if>
</where>
</sql> <select id="findPageBy" parameterType="java.util.Map" resultMap="pageViewResultMap">
<include refid="mainSql"/>
<include refid="varSql"/>
<if test="SORT != null and SORT != ''">
order by ${SORT}
<if test="DIR != null and DIR != ''">
${DIR}
</if>
</if>
</select> <select id="getById" parameterType="String" resultMap="pageViewResultMap">
<include refid="mainSql"/>
where <include refid="conditionOnlyId"/>
</select> <select id="getCountBy" parameterType="java.util.Map" resultType="INTEGER">
SELECT
COUNT(*) AS C
FROM
<include refid="tableNameSql"/> p
<include refid="varSql"/>
</select> <select id="findListBy" parameterType="java.util.Map" resultMap="pageViewResultMap">
<include refid="mainSql"/>
<include refid="varSql"/>
<if test="SORT != null and SORT != ''">
order by ${SORT}
<if test="DIR != null and DIR != ''">
${DIR}
</if>
</if>
</select> <insert id="save" parameterType="com.liupengyuan.test.modulePage.pageView.model.PageView">
insert into
<include refid="tableNameSql"/>
(
<include refid="commonSelectColumnsPrefix"/>
)
values
(
#{id, jdbcType=VARCHAR} ,
#{requestIp, jdbcType=VARCHAR} ,
#{session, jdbcType=VARCHAR} ,
#{module, jdbcType=VARCHAR} ,
#{visitTime, jdbcType=TIMESTAMP} ,
#{visitCount, jdbcType=INTEGER}
)
</insert>
<update id="update" parameterType="com.liupengyuan.test.modulePage.pageView.model.PageView">
update
<include refid="tableNameSql"/>
set
request_ip = #{requestIp, jdbcType=VARCHAR} ,
session = #{session, jdbcType=VARCHAR} ,
module = #{module, jdbcType=VARCHAR} ,
visit_time = #{visitTime, jdbcType=TIMESTAMP} ,
visit_count = #{visitCount, jdbcType=INTEGER}
where <include refid="conditionOnlyId"/>
</update> <delete id="deleteByIds" parameterType="Object[]">
delete from <include refid="tableNameSql"/>
where id in <foreach index="index" item="item" collection="array" separator="," open="(" close=")" >#{item}</foreach>
</delete> <delete id="deleteById" parameterType="Object">
delete from <include refid="tableNameSql"/> where <include refid="conditionOnlyId"/>
</delete> </mapper>

spring配置文件:spring-test-modulePage-pageView.xml

<?xml version="1.0" encoding="UTF-8"?

>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="com.liupengyuan.test.modulePage.pageView.*" />
</beans>

Struts2配置文件:struts-test-modulePage-pageView.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="com.liupengyuan.test.modulePage.pageView.action.PageViewAction" extends="struts-default" namespace="/jsp/moduleWeb/pageView"> <action name="pageView_*"
class="pageViewAction"
method="{1}">
</action>
<action name="pageView">
<result>/jsp/moduleWeb/pageView/pageView.jsp</result>
</action> </package>
</struts>

结束...

集成框架 javaweb开发平台ssmy_m(生成代码) java struts2 mybatis spring maven jquery的更多相关文章

  1. zwPython,字王集成式python开发平台,比pythonXY更强大、更方便。

    zwPython,字王集成式python开发平台,比pythonXY更强大.更方便. 更强大,内置opencv.cuda/opencl.NLTK自然语言.pygame游戏设计等多个重量级模块库. 更方 ...

  2. 接入Gobelieve IM开发平台的DEMO代码

    接入Gobelieve IM开发平台的DEMO代码, 请求头部: Authorization: Basic $base64(appid:$hex_md5(appsecret))意思是 appsecre ...

  3. 【iCore3应用开发平台】发布 iCore3 应用开发平台PID控制代码

    说明:1.本代码包包含FPGA和STM32F407两部分内容2.FPGA工程为出厂代码FPGA工程,版本为REV43.STM32F407为只含PID控制的ARM工程4.在使用风扇过程中,请勿将手伸入扇 ...

  4. struts2 mybatis spring hibernate 框架 pom.xml配置 下载地址

    访问以下地址:搜索需要框架的配置  选择需要的版本 http://mvnrepository.com

  5. 开发框架-移动开发平台: mPaaS

    ylbtech-开发框架-移动开发平台: mPaaS 移动开发平台 mPaaSmPaaS(Mobile PaaS)为 App 开发.测试.运营及运维提供云到端的一站式解决方案,能有效降低技术门槛.减少 ...

  6. MVPArms MVP快速集成框架

    前言 今年的Android技术圈中MVP,Dagger2,Rxjava,Retrofit这些词汇非常火,随便打开一个技术论坛都充斥着大量的关于这些技术的文章,Github也充斥着各种以基于MVP+Re ...

  7. 基于MINA框架快速开发网络应用程序

    1.MINA框架简介 MINA(Multipurpose Infrastructure for Network Applications)是用于开发高性能和高可用性的网络应用程序的基础框架.通过使用M ...

  8. 使用Jquery+EasyUI进行框架项目开发案例讲解之一---员工管理源码分享

    使用Jquery+EasyUI进行框架项目开发案例讲解之一---员工管理源码分享 使用Jquery+EasyUI 进行框架项目开发案例讲解之一 员工管理源码分享    在开始讲解之前,我们先来看一下什 ...

  9. mybatis 自动生成代码(mybatis generator)

    pom.xml 文件配置 引入 mybatis generator <properties> <mysql.connector.version>5.1.44</mysql ...

随机推荐

  1. read table 时关键字TRANSPORTING NO FIELDS的用法

    关键字TRANSPORTING NO FIELDS 用于read table with key 一般用于等读取内表的时候,只是判断该内表中是否有次数据 不需要读取到工作区中. READ TABLE g ...

  2. Qt制作应用插件

    在Qt下,插件有两种形式,一种是用于QtCreator下,扩展IDE功能.另一种是用于扩展开发者的应用.本文要讲的是后者. 定义一个纯虚类作为插件接口 #include <QtPlugin> ...

  3. 正則表達式验证邮箱,qq,座机,手机,网址

    手机: var reg=/^1[34578]\d{9}$/; if(reg.test("你输入的手机号码") ) { alert("手机号码输入正确") } e ...

  4. HealthKit开发教程Swift版:起步

    原文:HealthKit Tutorial with Swift: Getting Started 作者:Ernesto García 译者:Mr_cyz ) HealthKit是iOS 8中的新的A ...

  5. hdu 1028 母函数 一个数有几种相加方式

    ///hdu 1028 母函数 一个数有几种相加方式 #include<stdio.h> #include<string.h> #include<iostream> ...

  6. Google 搜索的基本语法

    ★搜索引擎的选择 先简单说一下"搜索引擎的选择". 在咱们天朝,Google 屡屡被 GFW 骚扰,导致百度占了便宜,成为份额最高的搜索引擎.不过今天这篇教程,俺还是继续拿 Goo ...

  7. Android开发周报:Android L默认加密用户数据

    Android开发周报:Android L默认加密用户数据 新闻 <iCloud前车之鉴,Android L默认开启加密功能>:iCloud 艳照风波再起,第二波女星照片流出,大量女星的裸 ...

  8. UVAlive 2519 Radar Installation (区间选点问题)

    Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. ...

  9. QT4和QT3的区别

    著名的QT库前一阵子升级到4.xx版本了,我目前在开发的一个基于QT3的软件,由于受到QThread的各种困扰,因此打算尝试将代码升级到QT4, 但是当我实际开始升级工作后,才发现QT3和QT4的变化 ...

  10. 【C语言疯狂讲义】(八)C语言一维数组

    1.数组的基本概念: 同样类型    若干个     有序 由若干个同样类型的数据组成的有序的集合 有序:存储地址连续 下标连续 数组名:用来存放数组首地址的变量 数组元素:构成数组的每个数据 数组的 ...