SSM框架搭建實例

SSM框架搭建簡單實例 - 搭建步驟


需求分析:

   實現用戶表信息的增刪改查


1. 開發環境

  • 環境  : JDK  1.8         
  • 軟件 : myeclipse       
  • 數據庫 : MySql

2. 創建數據庫

  • 數據庫名稱:ssm           
  • 字符集:UTF-8         
  • 表 : user

3. 工程搭建

  •   工程使用Springmvc、spring、mybatis框架整合完成。
  • 項目完整目錄截圖

4. 創建web工程

  • 準備需要的jar包
  1. spring(包括springmvc)
  2. mybatis
  3. mybatis-spring整合包
  4. 數據庫驅動
  5. 第三方連接池。
  6. Json依賴包(springmvc 自帶,可不加)
  • web.xml  文件

       需要配置的有  : Spring監聽器, SpringMVC 核心前端控制器, 字符集過濾器

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>SSM</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  
  <!-- Spring 監聽器 -->
  <context-param>
  	<param-name>contextConfigLocation</param-name>
  	<param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <listener>
  	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
  <!-- 配置 SpingMVC 核心前端處理器 -->
  <servlet>
  	<servlet-name>springmvcDispatcherServlet</servlet-name>
  	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  	<init-param>
  		<param-name>contextConfigLocation</param-name>
  		<param-value>classpath:springmvc.xml</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>springmvcDispatcherServlet</servlet-name>
  	<url-pattern>*.action</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>

三個框架的配置文件,統一放在 conf 文件夾下(source folder 文件夾)

  • applicationContext.xml    【Spring 的 配置文件】

<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
	http://www.springframework.org/schema/util 
	http://www.springframework.org/schema/util/spring-util-4.3.xsd
	http://www.springframework.org/schema/context 
	http://www.springframework.org/schema/context/spring-context-4.3.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
	http://www.springframework.org/schema/mvc
	http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">
	
	<!-- 自動掃描註解 spring 負責dao/mapper和service 層 -->
	<context:component-scan base-package="top.vkiss.ssm.mapper"></context:component-scan>
	<context:component-scan base-package="top.vkiss.ssm.service"></context:component-scan>
	
	<!-- 讀取db.properties -->
	<context:property-placeholder location="classpath:db.properties"/>
	
	<!-- 配置數據源   -不讀取 db.properties 時,直接在 value屬性中賦予數據庫連接屬性值-->
	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="${driverClass}"></property>	
		<property name="url" value="${url}"></property>	
		<property name="username" value="${user}"></property>	
		<property name="password" value="${pwd}"></property>	
	</bean>
	
	<!-- 配置 SQLSessionFactory -->
	<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 加載數據源 -->
		<property name="dataSource" ref="dataSource"></property>
		<!-- 自動掃描 Mapper 文件 -->
		<property name="mapperLocations" value="classpath:top/vkiss/ssm/mapper/*.xml"></property>
		<!-- 屬性文件 -->
		<property name="configLocation" value="classpath:SqlMapConfig.xml"></property>
	</bean>
	
	<!-- 自掃描Dao/Mapper接口類,生成實體類 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- 掃描制定包的接口 -->
		<property name="basePackage" value="top.vkiss.ssm.mapper"></property>
		<!-- 注入 SqlSessinFaction bean -->
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"></property>
	</bean>
		
	<!-- 事務管理器 -->
	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource"></property>
	</bean>
	
	<!-- 事務通知 -->
	<tx:advice id="txAcvice" transaction-manager="transactionManager">
		<!--事務的傳播屬性 -->
		<tx:attributes>
			<tx:method name="add*" propagation="REQUIRED"/>
			<tx:method name="edit*" propagation="REQUIRED"/>
			<tx:method name="del*" propagation="REQUIRED"/>
			<tx:method name="save*" propagation="REQUIRED"/>
			<tx:method name="update*" propagation="REQUIRED"/>
			<tx:method name="insert*" propagation="REQUIRED"/>
			<tx:method name="get*" propagation="REQUIRED" read-only="true"/>
			<tx:method name="query*" propagation="REQUIRED" read-only="true"/>
			<!-- 簡單的可以直接配置  name="*"   -->
			<tx:method name="*" propagation="REQUIRED"/>
		</tx:attributes>
	</tx:advice>
	
	<!-- AOP 面向切面事務 -->
	<aop:config>
		<aop:pointcut expression="execution( * top.vkiss.ssm.service.*.*(..))" id="exep1"/>
		<aop:advisor advice-ref="txAcvice" pointcut-ref="exep1"/>		
	</aop:config>
	
</beans>
  • springmvc.xml    【SpringMVC 的 配置文件】

<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
	http://www.springframework.org/schema/util 
	http://www.springframework.org/schema/util/spring-util-4.3.xsd
	http://www.springframework.org/schema/context 
	http://www.springframework.org/schema/context/spring-context-4.3.xsd
	http://www.springframework.org/schema/aop 
	http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
	http://www.springframework.org/schema/tx 
	http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
	http://www.springframework.org/schema/mvc 
	http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
	http://www.springframework.org/schema/task 
	http://www.springframework.org/schema/task/spring-task-4.3.xsd">

	<!-- 掃描 處理器 bean 的 註解 -->
	<context:component-scan base-package="top.vkiss.ssm.controller"></context:component-scan>
	<context:component-scan base-package="top.vkiss.ssm.task"></context:component-scan>
	
	<!-- MVC 註解驅動 -->
	<mvc:annotation-driven></mvc:annotation-driven>
	
	<!-- 定時器註解驅動 -->
	<task:annotation-driven/>
	
	<!--  非註解 -配置 任務定時器    -配置文件加載時,先加載spring的配置文件,可能會出現不能執行的情況,當SpringMVC配置文件加載時,定時器方能執行
	<bean id="ta" class="top.vkiss.ssm.task.myTask"></bean>
	<task:scheduled-tasks>
		<task:scheduled ref="ta" method="zhh" cron="*/10 * * * * ?"/>
	</task:scheduled-tasks>	
	-->
	
	<!-- 視圖解析器 -->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<!-- 配置視圖地址的前綴 -->
		<property name="prefix" value="/jsp/"></property>
		<!-- 配置視圖地址的後綴 -->
		<property name="suffix" value=".jsp"></property>
	</bean>

</beans>
  • SqlMapConfig.xml    【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>
	
	<settings>
        <!-- 二級緩存 默認爲true  可不寫 --> 
		<setting name="cacheEnabled" value="true"/>
        <!-- 懶加載 / 延遲加載 默認爲true  可不寫 --> 
		<setting name="lazyLoadingEnabled" value="true"/>
		<!-- 修改該配置爲  按需加載 -->
		<setting name="aggressiveLazyLoading" value="false"/>
	</settings>
	
	<typeAliases>
		<package name="top.vkiss.ssm.domain"/>
	</typeAliases>
	
</configuration>
  • db.properties        【數據庫配置文件】

driverClass=com.mysql.jdbc.Driver
url=jdbc\:mysql\://localhost\:3306/ssm
user=root
pwd=root
  • log4j.properties    【日誌配置文件】

# Global logging configuration
#\u5728\u5f00\u53d1\u73af\u5883\u4e0b\u65e5\u5fd7\u7ea7\u522b\u8981\u8bbe\u7f6e\u6210DEBUG\uff0c\u751f\u4ea7\u73af\u5883\u8bbe\u7f6e\u6210info\u6216error
log4j.rootLogger=DEBUG, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n

 

  • User.java     【實體類 POJO,     所在包:top.vkiss.ssm.domain】

package top.vkiss.ssm.domain;

public class User {
    private Integer uid;
    private String uname;
    private String phone;
    private String address;
    // 這裏省略了getter / setter  方法
}
  • UserMapper.java    【dao層接口,     所在包:top.vkiss.ssm.mapper】

package top.vkiss.ssm.mapper;

import java.util.List;

import top.vkiss.ssm.domain.User;

public interface UserMapper {
	
	public void addUser(User user) throws Exception;
	public void delUser(Integer id) throws Exception;
	public void editUser(User user) throws Exception;
	public User getUser(Integer id) throws Exception;
	public List<User> queryAll() throws Exception;

}
  • UserMapper.xml  【dao層mybatis 映射文件,可逆向生成   所在包:top.vkiss.ssm.mapper】

<?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="top.vkiss.ssm.mapper.UserMapper" >

  <resultMap id="BaseResultMap" type="top.vkiss.ssm.domain.User" >
    <id column="uid" property="uid" jdbcType="INTEGER" />
    <result column="uname" property="uname" jdbcType="VARCHAR" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="address" property="address" jdbcType="VARCHAR" />
  </resultMap>
  
  <sql id="Base_Column_List" >
    uid, uname, phone, address
  </sql>
  
  <!-- 查一條 -->
  <select id="getUser" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from user
    where uid = #{uid,jdbcType=INTEGER}
  </select>
  
  <!-- 查所有 -->
  <select id="queryAll" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from user
  </select>
  
  <!-- 刪一條 -->
  <delete id="delUser" parameterType="java.lang.Integer" >
    delete from user
    where uid = #{uid,jdbcType=INTEGER}
  </delete>
  
		  <!-- 添加一條 
		  <insert id="insert" parameterType="top.vkiss.ssm.domain.User" >
		    insert into user (uid, uname, phone, 
		      address)
		    values (#{uid,jdbcType=INTEGER}, #{uname,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, 
		      #{address,jdbcType=VARCHAR})
		  </insert>
		  -->
		  
  <!-- 添加一條 -->
  <insert id="addUser" parameterType="top.vkiss.ssm.domain.User" >
    insert into user
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="uid != null" >
        uid,
      </if>
      <if test="uname != null" >
        uname,
      </if>
      <if test="phone != null" >
        phone,
      </if>
      <if test="address != null" >
        address,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="uid != null" >
        #{uid,jdbcType=INTEGER},
      </if>
      <if test="uname != null" >
        #{uname,jdbcType=VARCHAR},
      </if>
      <if test="phone != null" >
        #{phone,jdbcType=VARCHAR},
      </if>
      <if test="address != null" >
        #{address,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  
  <!-- 更新 -->
  <update id="editUser" parameterType="top.vkiss.ssm.domain.User" >
    update user
    <set >
      <if test="uname != null" >
        uname = #{uname,jdbcType=VARCHAR},
      </if>
      <if test="phone != null" >
        phone = #{phone,jdbcType=VARCHAR},
      </if>
      <if test="address != null" >
        address = #{address,jdbcType=VARCHAR},
      </if>
    </set>
    where uid = #{uid,jdbcType=INTEGER}
  </update>

</mapper>
  • UserService.java  【Servioce 層接口 ,     所在包:top.vkiss.ssm.service】

package top.vkiss.ssm.service;

import java.util.List;

import top.vkiss.ssm.domain.User;

public interface UserService {
	public void addUser(User user) throws Exception;
	public void delUser(Integer id) throws Exception;
	public void editUser(User user) throws Exception;
	public User getUser(Integer id) throws Exception;
	public List<User> queryAll() throws Exception;
}
  • UserServiceImpl.java   【Servioce 層實現類 ,     所在包:top.vkiss.ssm.service】

package top.vkiss.ssm.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.vkiss.ssm.domain.User;
import top.vkiss.ssm.mapper.UserMapper;
@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper ud;
	@Override
	public void addUser(User user) throws Exception {
		// TODO Auto-generated method stub
		ud.addUser(user);
	}

	@Override
	public void delUser(Integer id) throws Exception {
		// TODO Auto-generated method stub
		ud.delUser(id);
	}

	@Override
	public void editUser(User user) throws Exception {
		// TODO Auto-generated method stub
		ud.editUser(user);
	}

	@Override
	public User getUser(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return ud.getUser(id);
	}

	@Override
	public List<User> queryAll() throws Exception {
		// TODO Auto-generated method stub
		return ud.queryAll();
	}

}
  • UserController.java   【Controller 層 接收前端請求 ,     所在包:top.vkiss.ssm.controller】

package top.vkiss.ssm.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import top.vkiss.ssm.domain.User;
import top.vkiss.ssm.service.UserService;

@Controller
public class UserController {
	@Autowired
	private UserService us;
	
	@RequestMapping("/queryAll")
	public String queryAll(Model model) throws Exception{
		model.addAttribute("uList", us.queryAll());
		return "shouye";
	}
	
	@RequestMapping("/addUser")
	public String addUser(User user) throws Exception {
		System.out.println("addUser:"+user);
		us.addUser(user);
		return "redirect:queryAll.action";
	}
	
	@RequestMapping("/delUser")
	public String delUser(Integer id) throws Exception {
		System.out.println("del_id:"+id);
		us.delUser(id);
		return "redirect:queryAll.action";
	}
	
	@RequestMapping("/delS")
	public String delS(int[] ids) throws Exception {
		System.out.println("del_id:"+ids);
		for (int i : ids) {
			us.delUser(i);
		}
		return "redirect:queryAll.action";
	}
	
	@RequestMapping("/editUser")
	public String editUser(User user) throws Exception {
		System.out.println(user.getUname());
		us.editUser(user);
		return "redirect:queryAll.action";
	}
	
	@RequestMapping("/getUser")
	public String getUser(Model model,Integer id) throws Exception {
		System.out.println(id);
		System.out.println("...."+us.getUser(id));
		model.addAttribute("u", us.getUser(id));
		return "edit";
	}
	
	@RequestMapping("/showAdd")
	public String showAdd() throws Exception {
		return "addUs";
	}
}
  • myTask.java   【其他  層   SpringMVC 定時器 ,     所在包:top.vkiss.ssm.task】

package top.vkiss.ssm.task;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 *  本項目中沒有用到,僅作學習使用
 */


@Component("task")
public class myTask {
	@Scheduled(cron="* * * * * *")
	public void zhh(){
		System.out.println("999999999999999");
	}
}

頁面資源

index.jsp   項目啓動用於重定向跳轉

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
response.sendRedirect("queryAll.action");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
    This is my JSP page. <br>
  </body>
</html>

shouye,jsp    列表頁 用於展示用戶數據

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
	
		function dels(){
			var ids= new Array();
			alert(ids);
			var bb = $("._checked").val();
			alert(bb);
			$.each($("table tbody input[type=checkbox]:checked"),function(){
				alert(1);
        	})
        	
       		alert("2");
		
		}
	
	</script>
  </head>
  
  <body>
    This Is My First SSM Application. <br>
    <div align="center">
    	<table >
	    	<tr>
	    		<td><button onclick="dels()">點擊刪除多條</button></td>
	    		<td>UID</td>
	    		<td>姓名</td>
	    		<td>性別</td>
	    		<td>地址</td>
	    		<td>操作</td>
	    	</tr>
	    	<tbody>
	    	<c:forEach items="${uList}" var="u">
		    	<tr>
		    		<td><input type="checkbox" name="checkbox" class="_checked" value="${u.uid }"> </td>
		    		<td>${u.uid }</td>
		    		<td>${u.uname }</td>
		    		<td>${u.phone }</td>
		    		<td>${u.address }</td>
		    		<td><a href="getUser.action?id=${u.uid }">【修改】</a><a href="delUser.action?id=${u.uid }">【刪除】</a></td>
		    	</tr>
	    	</c:forEach>
	    	</tbody>
    	</table>
    	<p><a href="showAdd.action">點擊添加</a></p>
    	<p></p>
    </div>
  </body>
</html>

addUs.jsp    添加用戶頁面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
	
	</script>
  </head>
  
  <body>
      <div align="center">
         <form action="addUser.action" method="post">
            <p>
            	姓名:<input type="text" name="uname" value="${u.name}"/>
            </p>
            <p>
         		性別:<input type="text" name="phone" value="${u.phone}"/>
            </p>
            <p>
       			地址:<input type="text" name="address" value="${u.address}"/>
            </p>
            <p>
             <input type="submit" value="提交"/>
            </p>
         </form>
      </div>
  </body>
</html>

edit.jsp        修改頁面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
      <div align="center">
         <form action="editUser.action" method="post">
            <p>
            	<input type="hidden" name="uid" value="${u.uid}"/>
            	姓名:<input type="text" name="uname" value="${u.uname}"/>
            </p>
            <p>
         		性別:<input type="text" name="phone" value="${u.phone}"/>
            </p>
            <p>
       			地址:<input type="text" name="address" value="${u.address}"/>
            </p>
            <p>
             <input type="submit" value="修改"/>
            </p>
         </form>
      </div>
  </body>
</html>

至此簡單SSM項目整合完畢

附帶項目源碼:SSM項目整合   

所用Jar包 截圖

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章