4.0.2.RELEASE
3.2.6
1.7.7
1.2.17
junit
junit
4.11
test
org.springframework
spring-core
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-oxm
${spring.version}
org.springframework
spring-tx
${spring.version}
org.springframework
spring-jdbc
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-aop
${spring.version}
org.springframework
spring-context-support
${spring.version}
org.springframework
spring-test
${spring.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
javax
javaee-api
7.0
mysql
mysql-connector-java
5.1.30
commons-dbcp
commons-dbcp
1.2.2
jstl
jstl
1.2
log4j
log4j
${log4j.version}
com.alibaba
fastjson
1.1.41
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
org.codehaus.jackson
jackson-mapper-asl
1.9.13
commons-fileupload
commons-fileupload
1.3.1
commons-io
commons-io
2.4
commons-codec
commons-codec
1.9
2、创建jdbc.properties文件,配置MySQL数据库的基本信息
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/erp2
username=root
password=123456
Archetype Created Web Application
contextConfigLocation
classpath:applicationContext.xml
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
encodingFilter
*.action
*.do
*.view
org.springframework.web.context.ContextLoaderListener
org.springframework.web.util.IntrospectorCleanupListener
SpringMVC
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring-mvc.xml
1
SpringMVC
/
/index.jsp
text/html;charset=UTF-8
log4j.rootLogger=INFO,Console,File
#\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u76EE\u7684\u5730\u4E3A\u63A7\u5236\u53F0
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
#\u53EF\u4EE5\u7075\u6D3B\u5730\u6307\u5B9A\u65E5\u5FD7\u8F93\u51FA\u683C\u5F0F\uFF0C\u4E0B\u9762\u4E00\u884C\u662F\u6307\u5B9A\u5177\u4F53\u7684\u683C\u5F0F
log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n
#\u6587\u4EF6\u5927\u5C0F\u5230\u8FBE\u6307\u5B9A\u5C3A\u5BF8\u7684\u65F6\u5019\u4EA7\u751F\u4E00\u4E2A\u65B0\u7684\u6587\u4EF6
log4j.appender.File = org.apache.log4j.RollingFileAppender
#\u6307\u5B9A\u8F93\u51FA\u76EE\u5F55
log4j.appender.File.File = logs/ssm.log
#\u5B9A\u4E49\u6587\u4EF6\u6700\u5927\u5927\u5C0F
log4j.appender.File.MaxFileSize = 10MB
# \u8F93\u51FA\u6240\u4EE5\u65E5\u5FD7\uFF0C\u5982\u679C\u6362\u6210DEBUG\u8868\u793A\u8F93\u51FADEBUG\u4EE5\u4E0A\u7EA7\u522B\u65E5\u5FD7
log4j.appender.File.Threshold = ALL
log4j.appender.File.layout = org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern =[%p] [%d{yyyy-MM-dd HH\:mm\:ss}][%c]%m%n
package cn.zkz.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import cn.zkz.pojo.EmpModel;
import cn.zkz.service.EmpService;
@Controller
@RequestMapping("/emp")
public class EmpController {
@Resource
private EmpService empService;
@RequestMapping("/showEmp")
public String toIndex(HttpServletRequest request,Model model){
long empUuid = Integer.parseInt(request.getParameter("id"));
EmpModel em = this.empService.getEmById(empUuid);
model.addAttribute("em", em);
return "emp";
}
}
package cn.zkz.service.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.zkz.dao.EmpDao;
import cn.zkz.pojo.EmpModel;
import cn.zkz.service.EmpService;
public class EmpServiceImpl implements EmpService{
@Resource
private EmpDao empDao;
@Override
public EmpModel getEmById(Long empUuid) {
return this.empDao.selectByPrimaryKey(empUuid);
}
}
package cn.zkz.dao.impl;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import cn.zkz.dao.EmpDao;
import cn.zkz.pojo.EmpModel;
public class EmpDaoImpl implements EmpDao {
private SqlSessionFactory sqlSessionFactory;
public SqlSessionFactory getSqlSessionFactory() {
return sqlSessionFactory;
}
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
this.sqlSessionFactory = sqlSessionFactory;
}
@Override
public EmpModel selectByPrimaryKey(long empUuid) {
// 创建SqlSession
SqlSession sqlSession = this.sqlSessionFactory.openSession();
// 根据id查询用户信息
EmpModel em = sqlSession.selectOne("findUserById", empUuid);
return em;
}
}
package cn.zkz.pojo;
public class EmpModel {
private Long uuid;
private String username;
private String password;
private String name;
private String tele;
private Integer gerder;
public Long getUuid() {
return uuid;
}
public void setUuid(Long uuid) {
this.uuid = uuid;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTele() {
return tele;
}
public void setTele(String tele) {
this.tele = tele;
}
public Integer getGerder() {
return gerder;
}
public void setGerder(Integer gerder) {
this.gerder = gerder;
}
}