标签:plsql developer powerdesigner mybatis spring mvc oracle
我们来接着我们的项目写<!-- 新增 oracle jbdc驱动当这个值为null时,必须告诉它当前字段 默认值的类型jdbcType=VARCHAR(MyBatis定义),Mysql不用写--> <insert id="insert" parameterType="cn.hpu.jk.domain.Factory"> insert into factory_c (FACTORY_ID,FULL_NAME,FACTORY_NAME,CONTACTS,PHONE,MOBILE,FAX,CNOTE, INSPECTOR,ORDER_NO,CREATE_BY,CREATE_DEPT,CREATE_TIME) values ( #{id}, #{fullName,jdbcType=VARCHAR}, #{factoryName,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{fax,jdbcType=VARCHAR}, #{cnote,jdbcType=VARCHAR}, #{inspector,jdbcType=VARCHAR}, #{orderNo,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, #{creatDept,jdbcType=VARCHAR}, #{creatTime,jdbcType=TIMESTAMP} ) </insert>
public void insert(T entity) { this.getSqlSession().insert(ns + ".insert", entity); }而我们的FactoryDaoImpl已经继承了BaseDaoImpl,所以不用再写。
@Override public void insert(Factory factory) { //设置UUID factory.setId(UUID.randomUUID().toString()); factoryDao.insert(factory); }
//转向新增页面 @RequestMapping("/basicinfo/factory/tocreate.action") public String tocreate(){ return "/baseinfo/factory/jFactoryCreate.jsp"; } //进行新增 @RequestMapping("/basicinfo/factory/insert.action") public String insert(Factory factory){ factoryService.insert(factory); return "redirect:/basicinfo/factory/list.action";//转向列表action }
<%@ page language="java" pageEncoding="UTF-8"%> <%@ include file="../../base.jsp"%> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>添加厂家信息</title> </head> <body> <form method="post"> <div id="menubar"> <div id="middleMenubar"> <div id="innerMenubar"> <div id="navMenubar"> <ul> <li id="save"><a href="#" onclick="formSubmit('insert.action','_self');">确定</a></li> <li id="back"><a href="list.action">返回</a></li> </ul> </div> </div> </div> </div> <div class="textbox" id="centerTextbox"> <div class="textbox-header"> <div class="textbox-inner-header"> <div class="textbox-title"> 新增生产厂家信息 </div> </div> </div> <div> <div> <table class="commonTable" cellspacing="1"> <tr> <td class="columnTitle_mustbe">厂家名称:</td> <td class="tableContent"><input type="text" name="fullName" /></td> <td class="columnTitle_mustbe">简称:</td> <td class="tableContent"><input type="text" name="factoryName" /></td> </tr> <tr> <td class="columnTitle_mustbe">联系人:</td> <td class="tableContent"><input type="text" name="contacts" /></td> <td class="columnTitle_mustbe">电话:</td> <td class="tableContent"><input type="text" name="phone" /></td> </tr> <tr> <td class="columnTitle_mustbe">手机:</td> <td class="tableContent"><input type="text" name="mobile" /></td> <td class="columnTitle_mustbe">传真:</td> <td class="tableContent"><input type="text" name="fax" /></td> </tr> <tr> <td class="columnTitle_mustbe">检验员:</td> <td class="tableContent"><input type="text" name="inspector" /></td> <td class="columnTitle_mustbe">排序号:</td> <td class="tableContent"><input type="text" name="orderNo" /></td> </tr> <tr> <td class="columnTitle_mustbe">备注:</td> <td class="tableContent"><textarea name="cnote" style="height:200px;width: 400px"></textarea></td> </tr> </table> </div> </div> </form> </body> </html>
<ul> <li id="view"><a href="#" onclick="formSubmit('toview.action','_self');this.blur();">查看</a></li> <li id="new"><a href="#" onclick="formSubmit('tocreate.action','_self');this.blur();">添加</a></li> </ul>
log4j.rootLogger=info, stdout #Console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%-5p - %m%n #LogFile log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=../logs/jklog.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n #Daily LogFile log4j.appender.dayfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.dayfile.File=../logs/jklog.log log4j.appender.dayfile.DatePattern='.'yyyy-MM-dd'.log' log4j.appender.dayfile.Append=true log4j.appender.dayfile.layout=org.apache.log4j.PatternLayout log4j.appender.dayfile.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n # LOGIN_LOG_P db config ### log4j.appender.logindb=org.apache.log4j.jdbc.JDBCAppender log4j.appender.logindb.BufferSize=1 log4j.appender.logindb.driver=com.mysql.jdbc.Driver log4j.appender.logindb.URL=jdbc:mysql://localhost:3306/jkdb?characterEncoding=utf-8 log4j.appender.logindb.user=root log4j.appender.logindb.password=root ## MySQL #log4j.appender.logindb.sql=INSERT INTO LOGIN_LOG_P(LOGIN_LOG_ID,LOGIN_NAME,IP_ADDRESS,LOGIN_TIME) VALUES(uuid(),'%X{userId}|%X{userName}','%X{ip}','%d{yyyy-MM-dd HH:mm:ss}') log4j.appender.logindb.sql=INSERT INTO LOGIN_LOG_P(LOGIN_LOG_ID,LOGIN_NAME,IP_ADDRESS,LOGIN_TIME) VALUES(uuid(),'','',NOW()) log4j.appender.logindb.layout=org.apache.log4j.PatternLayout log4j.logger.org.apache=INFO log4j.logger.cn.itcast.jk=DEBUG
返回列表界面,发现编辑成功!
转载请注明出处:http://blog.csdn.net/acmman/article/details/48261851
版权声明:本文为博主原创文章,未经博主允许不得转载。
【springmvc+mybatis项目实战】杰信商贸-7.生产厂家新增
标签:plsql developer powerdesigner mybatis spring mvc oracle
原文地址:http://blog.csdn.net/acmman/article/details/48261851