一.SpringMVC和Mybatis整合
1.所需jar包
1.1 Spring(包括SpringMVC)所需jar包
1.2 MyBatis所需jar包
1.3 mybatis-spring整合包
1.4数据库驱动包
1.5第三方数据库连接池
2.整合Dao层
2.1配置
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ehr
jdbc.username=root
jdbc.password=203629
2.2配置
#定义LOG输出级别
log4j.rootLogger=INFO,Console,File
#定义日志输出目的地为控制台
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
#可以灵活地指定日志输出格式,下面一行是指定具体的格式log4j.appender.Console.layout = org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c] - %m%n
#文件大小到达指定尺寸的时候产生一个新的文件
log4j.appender.File = org.apache.log4j.RollingFileAppender
#指定输出目录
log4j.appender.File.File = D\:logs/ssm.log
#定义文件最大大小
log4j.appender.File.MaxFileSize = 10MB
#输出所以日志,如果换成DEBUG表示输出DEBUG以上级别日志
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
2.3配置mybatis全局配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<package name="com.neuedu.pojo"/>
</typeAliases>
</configuration>
2.4配置spring配置文件
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<!-- 加载db.properties文件中的内容,db.properties文件中key命名要有一定的特殊规则 -->
<!-- <properties resource="db.properties"></properties> -->
<!-- 配置数据源 ,dbcp -->
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/ehr" />
<property name="username" value="root" />
<property name="password" value="123" />
</bean>
<!--
2. mybatis的SqlSession的工厂: SqlSessionFactoryBean dataSource:引用数据源
MyBatis定义数据源,同意加载配置
-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<!-- 读取mybatis中的配置 例如别名配置 全局设置 -->
<property name="configLocation" value="classpath:config/sqlMapConfig.xml" />
</bean>
<!--
3. mybatis自动扫描加载Sql映射文件/接口 : MapperScannerConfigurer sqlSessionFactory
basePackage:指定sql映射文件/接口所在的包(自动扫描)
-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.neuedu.mapper"></property>
<property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!--
4. 事务管理 : DataSourceTransactionManager dataSource:引用上面定义的数据源
-->
<bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 5. 使用声明式事务
transaction-manager:引用上面定义的事务管理器
-->
<tx:annotation-driven transaction-manager="txManager" />
</beans>
3.整合Service层
3.1配置
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
<!-- service -->
<bean id="UserService" class="com.neuedu.service.UserServiceImpl"/>
</beans>
3.2配置
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd ">
<!-- 事务管理器
对mybatis操作数据库事务控制,spring使用jdbc的事务控制类
-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 数据源
dataSource在applicationContext-dao.xml中配置了
-->
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 传播行为 -->
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="select*" propagation="SUPPORTS" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- aop -->
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.neuedu.service.*.*(..))"/>
</aop:config>
</beans>
4.整合表现层
4.1配置处理器映射器、处理器适配器和视图解析器
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- 注解扫描包 -->
<context:component-scan base-package="com.neuedu" />
<!-- 开启注解 -->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,需要重新设置spring-mvc-3.0.xsd -->
<!-- <mvc:resources mapping="/image/**" location="/image/" />
<mvc:resources mapping="/img/**" location="/img/" />
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:resources mapping="/css/**" location="/css/" />
<mvc:resources mapping="/html/**" location="/html/" /> -->
<!-- 解决静态资源访问 -->
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<mvc:resources location="/js/" mapping="/js/**" />
<mvc:resources location="/css/" mapping="/css/**" />
<mvc:resources location="/image/" mapping="/image/**" />
<mvc:resources location="/images/" mapping="/images/**" />
<mvc:resources location="/imagess/" mapping="/imagess/**" />
<!-- 定义跳转的文件的前后缀 ,视图模式配置-->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 配置jsp路径的前缀 -->
<property name="prefix" value="/" />
<!-- 配置jsp路径的后缀 -->
<property name="suffix" value=".jsp" />
</bean>
</beans>
4.2配置前端控制器
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>ehr</display-name>
<welcome-file-list>
<welcome-file>RSGL_index.html</welcome-file>
<welcome-file>RSGL_index.htm</welcome-file>
<welcome-file>RSGL_index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- 配置前端控制器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!---->
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- -->
<param-value>classpath:config/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
二.具体代码编写流程(以部门管理为例)
1.Dao层代码的编写,生成pojo类及mapper
1.1
package com.neuedu.pojo;
public class Department {
private Integer dp_id;
private String dp_name;
private Integer dp_tele;
private String dp_fd;
public Department() {
super();
}
public Department(Integer dp_id, String dp_name, Integer dp_tele, String dp_fd) {
super();
this.dp_id = dp_id;
this.dp_name = dp_name;
this.dp_tele = dp_tele;
this.dp_fd = dp_fd;
}
public Integer getDp_id() {
return dp_id;
}
public void setDp_id(Integer dp_id) {
this.dp_id = dp_id;
}
public String getDp_name() {
return dp_name;
}
public void setDp_name(String dp_name) {
this.dp_name = dp_name;
}
public Integer getDp_tele() {
return dp_tele;
}
public void setDp_tele(Integer dp_tele) {
this.dp_tele = dp_tele;
}
public String getDp_fd() {
return dp_fd;
}
public void setDp_fd(String dp_fd) {
this.dp_fd = dp_fd;
}
}
1.2
1.2.1
package com.neuedu.mapper;
import com.neuedu.pojo.Department;
import com.neuedu.pojo.Post;
import com.neuedu.pojo.Staff;
public interface UserMapper {
//部门管理
public Department findDepartmentListByIdAndName(Integer dp_id,String dp_name)throws Exception;
public int insertDepartment(Department department)throws Exception;
public int updateDepartment(Department department)throws Exception;
public Department findDepartmentListById(Integer dp_id)throws Exception;
public int deleteDepartment(Integer dp_id)throws Exception;
}
1.2.2
<?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.neuedu.mapper.UserMapper">
<select id="findDepartmentListByIdAndName" resultType="com.neuedu.pojo.Department">
SELECT dp_id,dp_name,dp_tele,dp_fd
FROM department
WHERE dp_id=#{0} and dp_name=#{1}
</select>
<select id="findDepartmentListById" resultType="com.neuedu.pojo.Department">
SELECT dp_id,dp_name,dp_tele,dp_fd
FROM department
WHERE dp_id=#{dp_id}
</select>
<insert id="insertDepartment" parameterType="com.neuedu.pojo.Department" >
INSERT INTO department(dp_id,dp_name,dp_tele,dp_fd) VALUES(#{dp_id},#{dp_name},#{dp_tele},#{dp_fd})
</insert>
<update id="updateDepartment" parameterType="com.neuedu.pojo.Department">
UPDATE department
SET dp_name=#{dp_name},dp_tele=#{dp_tele},dp_fd=#{dp_fd}
WHERE dp_id=#{dp_id}
</update>
<delete id="deleteDepartment" parameterType="Integer">
DELETE FROM department
WHERE dp_id=#{dp_id}
</delete>
</mapper>
2.Service层代码的编写
2.1
package com.neuedu.service;
import com.neuedu.pojo.Department;
public interface UserService {
//部门管理
public Department findDepartmentListByIdAndName(Integer dp_id,String dp_name)throws Exception;
public int insertDepartment(Department department)throws Exception;
public int updateDepartment(Department department)throws Exception;
public Department findDepartmentListById(Integer dp_id)throws Exception;
public int deleteDepartment(Integer dp_id)throws Exception;
}
2.2
package com.neuedu.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.neuedu.mapper.UserMapper;
import com.neuedu.pojo.Department;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserMapper userMapper;
@Override
public Department findDepartmentListByIdAndName(Integer dp_id,String dp_name)throws Exception{
return userMapper.findDepartmentListByIdAndName(dp_id,dp_name);
}
public int insertDepartment(Department department)throws Exception{
return userMapper.insertDepartment(department);
}
public int updateDepartment(Department department)throws Exception{
return userMapper.updateDepartment(department);
}
@Override
public Department findDepartmentListById(Integer dp_id) throws Exception {
// TODO Auto-generated method stub
return userMapper.findDepartmentListById(dp_id);
}
public int deleteDepartment(Integer dp_id)throws Exception{
return userMapper.deleteDepartment(dp_id);
}
}
3.Web层代码的编写
package com.neuedu.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.neuedu.pojo.Department;
import com.neuedu.service.UserService;
@Controller
@RequestMapping(value="/user")
public class controller {
@Autowired
private UserService userService;
//查询Department
@RequestMapping(value="/findDepartmentListByIdAndName")
public ModelAndView findDepartmentListByIdAndName(Integer dp_id,String dp_name)throws Exception {
Department department = userService.findDepartmentListByIdAndName(dp_id, dp_name);
ModelAndView mv = new ModelAndView();
mv.addObject("department",department);
mv.setViewName("bumenguanli/save2_index2");
return mv;
}
@RequestMapping(value="/findDepartmentListById")
public ModelAndView findDepartmentListById(Integer dp_id)throws Exception {
Department department = userService.findDepartmentListById(dp_id);
ModelAndView mv = new ModelAndView();
mv.addObject("department",department);
mv.setViewName("bumenguanli/save2_index2");
return mv;
}
//插入Department
@RequestMapping(value="/addDepartment")
public ModelAndView addDepartment(Department department)throws Exception{
userService.insertDepartment(department);
ModelAndView mv = new ModelAndView();
mv.setViewName("save2_index1");
return mv;
}
//更新Department
@RequestMapping(value="/toupdateDepartment")
public ModelAndView toupdateDepartment(Integer dp_id)throws Exception{
Department department = userService.findDepartmentListById(dp_id);
ModelAndView mv = new ModelAndView();
mv.addObject("department",department);
mv.setViewName("bumenguanli/alter_index");
return mv;
}
@RequestMapping(value="/updateDepartment")
public ModelAndView updateDepartment(Department department)throws Exception{
int deptid = userService.updateDepartment(department);
ModelAndView mv = new ModelAndView();
mv.setViewName("bumenguanli/save2_index1");
return mv;
}
//删除Department
@RequestMapping(value="/deleteDepartment")
public ModelAndView deleteDepartment(Integer dp_id)throws Exception{
int count = userService.deleteDepartment(dp_id);
ModelAndView mv = new ModelAndView();
mv.setViewName("bumenguanli/save2_index1");
return mv;
}
}
4.前台jsp页面代码的编写
4.1
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Greeny Grass
Description: A two-column, fixed-width design.
Version : 1.0
Released : 20080208
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Greeny Grass by Free CSS Templates</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../default.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
<!--
.STYLE1 {
font-size: 18px;
color: #FFFFFF;
}
-->
</style>
<script language="javascript">
function fsubmit(obj){
obj.submit();
}
function freset(obj){
obj.reset();
}
function save2_index1(){
window.location.href="save2_index1.jsp";
}
</script>
<script>
function save2_index1(){
var dp_id =document.getElementById("dp_id").value;
var dp_name = document.getElementById("dp_name").value;
var dp_tele =document.getElementById("dp_tele").value;
var dp_fd = document.getElementById("dp_fd").value;
window.location.href="../user/addDepartment?dp_id="+dp_id+"&dp_name="+dp_name+"&dp_tele="+dp_tele+"&dp_fd="+dp_fd;
window.location.href="save2_index1.jsp";
}</script>
</head>
<body>
<div id="wrapper">
<!-- start header -->
<div id="header">
<h1>人事管理系统 </h1>
<p> design By Free CSS Templates</p>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">部门管理</h1>
<div class="entry">
<form id="backquery" name = "backquery">
<p align="center" class="STYLE1">新增部门详细</p>
<form name="add" id="add" method="post" >
<table width="66%" border="1" align="center" >
<tr>
<td>* 部门编号:</td>
<td><input type="text" name="dp_id" id="dp_id" maxlength="18"></td>
<!-- <input type="hidden" name="hidden" id="hidden" value=""> -->
</tr>
<!-- <tr>
<td>部门类型:</td>
<td align="left">
<select name="client">
<option ></option>
<option id="1" value="1">子公司</option>
<option id="2" value="2">部门</option>
</select> </td>
</tr> -->
<tr>
<td width="23%">* 部门名称:</td>
<td align="left"><input type="text" name="dp_name" id="dp_name" maxlength="80"></td>
</tr>
<tr>
<td>* 移动电话:</td>
<td><input type="text" name="dp_tele" id="dp_tele" onBlur="isPlane()"></td>
</tr>
<!-- <tr>
<td>传真:</td>
<td><input type="text" name="Fix1" id="login" onchange="isFix()"></td>
</tr>
<tr>
<td>描述:</td>
<td align="left"><input type="text" name="contact" id="contact" maxlength="20"></td>
</tr>
<tr>
<td>上级部门:</td>
<td align="left"><input type="text" name="sjbm" id="sjbm" maxlength="100"></td>
</tr>
<tr> -->
<td>* 成立日期:</td>
<td align="left"><input type="text" name="dp_fd" id="dp_fd" ></td></tr>
<tr>
<td height="49" colspan="2" align="center">
<input type="button" value="确定" " onClick="save2_index1()">
<input type="button" value="返回" onClick="save2_index1()"> </td>
</tr>
</table>
<div align="left"></div>
</form></p> </p>
<p> </p>
</form>
</div>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>管理</h2>
<ul>
<li><a href=".././RSGL_loginOK.jsp">主页</a></li>
<li><a href=".././bumenguanli/save2_index1.jsp">部门管理</a></li>
<li><a href=".././PositionManagement/PositionManagement.jsp">岗位管理</a></li>
<li><a href=".././renshiguanli/ptrz.jsp">入职管理</a></li>
<li><a href=".././renshiguanli/syq.jsp">试用期管理</a></li>
<li><a href=".././bumendiaodong/bumen_diaodong.jsp">部门调动管理</a></li>
<li><a href=".././gangweidiaodong/gangwei_diaodong.jsp">岗位调动管理</a></li>
<li><a href=".././lizhi_guanli/lizhi_guanli_banlilizhi.jsp">员工离职管理</a></li>
<li><a href=".././userinfo/search.jsp">员工信息中心</a></li>
</ul>
</li>
<li>
<h2>报表</h2>
<ul>
<li><a href=".././baobiao_guanli/baobiao_guanli_selectbiaoge.jsp">查看报表</a></li>
<li><a href=".././baobiao_guanli/baobiao_guanli_renshiyuebao.jsp">人事月报</a></li>
</ul>
</li>
</ul>
</div>
<!-- end sidebar -->
</div>
</div>
<!-- end page -->
<div id="footer">
<p> </p>
</div>
</body>
</html>
4.2
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Greeny Grass
Description: A two-column, fixed-width design.
Version : 1.0
Released : 20080208
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Greeny Grass by Free CSS Templates</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../default.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
<!--
.STYLE1 {font-size: 18px}
.STYLE3 {color: #FFFFFF}
-->
</style>
<script language="javascript">
function fsubmit(obj){
obj.submit();
}
function freset(obj){
obj.reset();
}
function save2_index2(){
var dp_id = document.getElementById("dp_id").value;
var dp_name = document.getElementById("dp_name").value;
var dp_tele = document.getElementById("dp_tele").value;
var dp_fd = document.getElementById("dp_fd").value;
window.location.href="../user/updateDepartment?dp_id="+dp_id+"&dp_name="+dp_name+"&dp_tele="+dp_tele+"&dp_fd="+dp_fd;
}
function save2_index1(){
window.location.href="../bumenguanli/save2_index1.jsp";
}
</script>
</head>
<body>
<div id="wrapper">
<!-- start header -->
<div id="header">
<h1>人事管理系统 </h1>
<p> design By Free CSS Templates</p>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">部门管理</h1>
<div class="entry">
<form id="backquery" name = "backquery">
<p><form name="add" id="add" method="post">
<table width="57%" border="1" align="center" >
<tr>
<td>* 部门编号:</td>
<td><input type="text" name="dp_id" id="dp_id" maxlength="18" value="${department.dp_id}"/></td>
</tr>
<tr>
<td width="23%">* 部门名称:</td>
<td align="left">
<input type="text" name="dp_name" id="dp_name" maxlength="80" value="${department.dp_name}"/></td>
</tr>
<tr>
<td>* 移动电话:</td>
<td><input type="text" name="dp_tele" id="dp_tele" value="${department.dp_tele}"/></td>
</tr>
<td>* 成立日期:</td>
<td align="left"><input type="text" name="dp_fd" id="dp_fd" value="${department.dp_fd}"/></td>
</tr>
<tr>
<td height="49" colspan="2" align="center">
<input type="button" value="确定" class="btn5" onclick="save2_index2()"></input>
<input type="reset" value="取消" class="btn5"></input>
<input type="button" value="返回" class="btn5" onclick="save2_index1()"></input></td>
</tr>
</table>
</form></p> </p>
<p> </p>
</form>
</div>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>管理</h2>
<ul>
<li><a href=".././RSGL_loginOK.jsp">主页</a></li>
<li><a href=".././bumenguanli/save2_index1.jsp">部门管理</a></li>
<li><a href=".././PositionManagement/PositionManagement.jsp">岗位管理</a></li>
<li><a href=".././renshiguanli/ptrz.jsp">入职管理</a></li>
<li><a href=".././renshiguanli/syq.jsp">试用期管理</a></li>
<li><a href=".././bumendiaodong/bumen_diaodong.jsp">部门调动管理</a></li>
<li><a href=".././gangweidiaodong/gangwei_diaodong.jsp">岗位调动管理</a></li>
<li><a href=".././lizhi_guanli/lizhi_guanli_banlilizhi.jsp">员工离职管理</a></li>
<li><a href=".././userinfo/search.jsp">员工信息中心</a></li>
</ul>
</li>
<li>
<h2>报表</h2>
<ul>
<li><a href=".././baobiao_guanli/baobiao_guanli_selectbiaoge.jsp">查看报表</a></li>
<li><a href=".././baobiao_guanli/baobiao_guanli_renshiyuebao.jsp">人事月报</a></li>
</ul>
</li>
</ul>
</div>
<!-- end sidebar -->
</div>
</div>
<!-- end page -->
<div id="footer">
<p> </p>
</div>
</body>
</html>
4.3
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Greeny Grass
Description: A two-column, fixed-width design.
Version : 1.0
Released : 20080208
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>Greeny Grass by Free CSS Templates</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../default.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
<!--
.STYLE4 {
font-size: 16px;
color: #FFFFFF;
}
-->
</style>
<script language="javascript">
function fsubmit(obj){
obj.submit();
}
function freset(obj){
obj.reset();
}
function save2_index1(){
window.location.href="save2_index1.jsp";
}
</script>
</head>
<body>
<div id="wrapper">
<!-- start header -->
<div id="header">
<h1>人事管理系统 </h1>
<p> design By Free CSS Templates</p>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">部门管理</h1>
<div class="entry">
<form id="backquery" name = "backquery">
<p align="center" class="STYLE4">xxx部门下的员工列表</p>
<table border="1" align="center">
<tr>
<td width="85" height="31" align="center">序号编号</td>
<td width="86"><div align="center">员工编号</div></td>
<td width="71" align="center">员工姓名</td>
<td width="88"><div align="center">岗位类型</div></td>
<td width="110" align="center">所属部门</td>
<td width="116"><div align="center">其他</div></td>
</tr>
<tr>
<td height="31" align="center">1</td>
<td><div align="center">3423324</div></td>
<td align="center">abc</td>
<td><div align="center">经理</div></td>
<td align="center">人事部</td>
<td><div align="center"></div></td>
</tr>
<tr>
<td height="31" align="center">2</td>
<td><div align="center">3423423</div></td>
<td align="center">efh</td>
<td><div align="center">部长</div></td>
<td align="center">东软集团</td>
<td><div align="center"></div></td>
</tr>
</table>
<p align="center"><input type="button" value="返回" onClick="save2_index1()"> </p>
</form>
</div>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>管理</h2>
<ul>
<li><a href=".././RSGL_loginOK.jsp">主页</a></li>
<li><a href=".././bumenguanli/save2_index1.jsp">部门管理</a></li>
<li><a href=".././PositionManagement/PositionManagement.jsp">岗位管理</a></li>
<li><a href=".././renshiguanli/ptrz.jsp">入职管理</a></li>
<li><a href=".././renshiguanli/syq.jsp">试用期管理</a></li>
<li><a href=".././bumendiaodong/bumen_diaodong.jsp">部门调动管理</a></li>
<li><a href=".././gangweidiaodong/gangwei_diaodong.jsp">岗位调动管理</a></li>
<li><a href=".././lizhi_guanli/lizhi_guanli_banlilizhi.jsp">员工离职管理</a></li>
<li><a href=".././userinfo/search.jsp">员工信息中心</a></li>
</ul>
</li>
<li>
<h2>报表</h2>
<ul>
<li><a href=".././baobiao_guanli/baobiao_guanli_selectbiaoge.jsp">查看报表</a></li>
<li><a href=".././baobiao_guanli/baobiao_guanli_renshiyuebao.jsp">人事月报</a></li>
</ul>
</li>
</ul>
</div>
<!-- end sidebar -->
</div>
</div>
<!-- end page -->
<div id="footer">
<p> </p>
</div>
</body>
</html>
4.4
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Greeny Grass
Description: A two-column, fixed-width design.
Version : 1.0
Released : 20080208
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>save2_index1</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../default.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
<!--
.STYLE1 {font-size: 18px}
.STYLE3 {color: #FFFFFF}
-->
</style>
<script language="javascript">
function fsubmit(obj){
obj.submit();
}
function freset(obj){
obj.reset();
}
</script>
<script >
function chaxun(){
var dp_id =document.getElementById("dp_id").value;
var dp_name = document.getElementById("dp_name").value;
precision.style.display="";
window.location.href="../user/findDepartmentListByIdAndName?dp_id="+dp_id+"&dp_name="+dp_name;
}
function add_index(){
window.location.href="add_index.jsp";
}
function employee_index(){
window.location.href="employee_index.jsp";
}
function alter_index(){
window.location.href="alter_index.jsp";
}
function save2_index1(){
window.location.href="save2_index1.jsp";
}
function fquery(){
alert("确定删除么?");
alert("删除成功!");
}
</script>
</head>
<body>
<div id="wrapper">
<!-- start header -->
<div id="header">
<h1>人事管理系统 </h1>
<p> design By Free CSS Templates</p>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">部门管理</h1>
<div class="entry">
<form id="backquery" name = "backquery" >
<p>编号
<input type="text" name="dp_id" size="25" id="dp_id"/>
名称
<input type="text" name="dp_name" size="25" id="dp_name"/>
<!-- 选择查询类型
<select id="s_state" name="">
<option value="正常">默认</option>
<option value="临界">子公司</option>
<option value="警戒">部门
</select> -->
</p>
<p align="center">
<input type="button" value="查询" class="btn5" onclick="chaxun()" align="middle" />
<input type="button" value="新增" class="btn5" onclick="add_index()" align="middle" />
</p>
<div id="precision" style="display:none" >
<table border="1">
<tr>
<td>部门编号:</td>
<td>部门名称:</td>
<td>部门电话</td>
<td>建立时间:</td>
</tr>
<tr>
<td>${department.dp_id}</td>
<td>${department.dp_name}</td>
<td>${department.dp_tele}</td>
<td>${department.dp_fd}</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>管理</h2>
<ul>
<li><a href=".././RSGL_loginOK.jsp">主页</a></li>
<li><a href=".././bumenguanli/save2_index1.jsp">部门管理</a></li>
<li><a href=".././PositionManagement/PositionManagement.jsp">岗位管理</a></li>
<li><a href=".././renshiguanli/ptrz.jsp">入职管理</a></li>
<li><a href=".././renshiguanli/syq.jsp">试用期管理</a></li>
<li><a href=".././bumendiaodong/bumen_diaodong.jsp">部门调动管理</a></li>
<li><a href=".././gangweidiaodong/gangwei_diaodong.jsp">岗位调动管理</a></li>
<li><a href=".././lizhi_guanli/lizhi_guanli_banlilizhi.jsp">员工离职管理</a></li>
<li><a href=".././userinfo/search.jsp">员工信息中心</a></li>
</ul>
</li>
<li>
<h2>报表</h2>
<ul>
<li><a href=".././baobiao_guanli/baobiao_guanli_selectbiaoge.jsp">查看报表</a></li>
<li><a href=".././baobiao_guanli/baobiao_guanli_renshiyuebao.jsp">人事月报</a></li>
</ul>
</li>
</ul>
</div>
<!-- end sidebar -->
</div>
</div>
<!-- end page -->
<div id="footer">
<p> </p>
</div>
</body>
</html>
4.5
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
Name : Greeny Grass
Description: A two-column, fixed-width design.
Version : 1.0
Released : 20080208
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>save2_index1</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="../default.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
<!--
.STYLE1 {font-size: 18px}
.STYLE3 {color: #FFFFFF}
-->
</style>
<script language="javascript">
function fsubmit(obj){
obj.submit();
}
function freset(obj){
obj.reset();
}
</script>
<script >
function chaxun(){
var dp_id =document.getElementById("dp_id").value;
var dp_name = document.getElementById("dp_name").value;
precision.style.display="";
window.location.href="../user/findDepartmentListByIdAndName?dp_id="+dp_id+"&dp_name="+dp_name;
}
function add_index(){
window.location.href="../bumenguanli/add_index.jsp";
}
function employee_index(){
window.location.href="employee_index.jsp";
}
function save2_index1(){
window.location.href="save2_index1.jsp";
}
function fquery(){
alert("确定删除么?");
var dp_id =document.getElementById("dp_id").value;
window.location.href="../user/deleteDepartment?dp_id="+dp_id;
alert("删除成功!");
window.location.href="../bumenguanli/save2_index1.jsp";
}
</script>
</head>
<body>
<div id="wrapper">
<!-- start header -->
<div id="header">
<h1>人事管理系统 </h1>
<p> design By Free CSS Templates</p>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">部门管理</h1>
<div class="entry">
<p>编号
<input type="text" name="dp_id" size="25" id="dp_id"/>
名称
<input type="text" name="dp_name" size="25" id="dp_name"/>
<!-- 选择查询类型
<select id="s_state" name="">
<option value="正常">默认</option>
<option value="临界">子公司</option>
<option value="警戒">部门
</select> -->
</p>
<p align="center">
<input type="button" value="查询" class="btn5" onclick="chaxun()" align="middle" />
<input type="button" value="新增" class="btn5" onclick="add_index()" align="middle" />
</p>
<table border="1">
<tr>
<td>部门编号:</td>
<td>部门名称:</td>
<td>部门电话</td>
<td>建立时间:</td>
<td><a href="toupdateDepartment?dp_id=${department.dp_id}">修改</a></td>
<td><a href="deleteDepartment?dp_id=${department.dp_id}">删除</a></td>
<!-- <td> <input type="button" value="删除" class="btn5" onclick="fquery()" align="middle" /> </td>-->
</tr>
<tr>
<td>${department.dp_id}</td>
<td>${department.dp_name}</td>
<td>${department.dp_tele}</td>
<td>${department.dp_fd}</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>管理</h2>
<ul>
<li><a href=".././RSGL_loginOK.jsp">主页</a></li>
<li><a href=".././bumenguanli/save2_index1.jsp">部门管理</a></li>
<li><a href=".././PositionManagement/PositionManagement.jsp">岗位管理</a></li>
<li><a href=".././renshiguanli/ptrz.jsp">入职管理</a></li>
<li><a href=".././renshiguanli/syq.jsp">试用期管理</a></li>
<li><a href=".././bumendiaodong/bumen_diaodong.jsp">部门调动管理</a></li>
<li><a href=".././gangweidiaodong/gangwei_diaodong.jsp">岗位调动管理</a></li>
<li><a href=".././lizhi_guanli/lizhi_guanli_banlilizhi.jsp">员工离职管理</a></li>
<li><a href=".././userinfo/search.jsp">员工信息中心</a></li>
</ul>
</li>
<li>
<h2>报表</h2>
<ul>
<li><a href=".././baobiao_guanli/baobiao_guanli_selectbiaoge.jsp">查看报表</a></li>
<li><a href=".././baobiao_guanli/baobiao_guanli_renshiyuebao.jsp">人事月报</a></li>
</ul>
</li>
</ul>
</div>
<!-- end sidebar -->
</div>
</div>
<!-- end page -->
<div id="footer">
<p> </p>
</div>
</body>
</html>
三.开发体会
通过实际项目的开发,我对ssm框架有了更深入的理解,比如说对象之间的依赖关系由spring控制,减小了耦合,简化了开发;再比如说mybatis支持动态的sql,数据库的操作采用xml文件配置,解除了sql和代码的耦合等。
随着由浅入深的学习,从对ssm框架一无所知到有所涉猎,我能体会到该框架的优势,以后也会继续学习。