eclipse(springmvc+spring+mybatis)(下)

eclipse(springmvc+spring+mybatis)


案例下载:SSM
整合包:springmvc+spring+mybatis


4、添加目录结构
这里写图片描述


5、导入SSM所需要的jar包
这里写图片描述


6、添加jsp
这里写图片描述
index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form action="<%=path %>/userController/login.do" method="post">
        <table>
            <tr>
                <td>用户名</td>
                <td><input type="text" name="ename"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" name="password"></td>
            </tr>
            <tr>
                <td><input type="submit" value="立即登陆"></td>
            </tr>
        </table>
    </form>
</body>
</html>

add.jsp

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'add.jsp' starting page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  </head>

  <body>
    <form action="<%=path %>/userController/add.do" method="post">
        <input type="hidden" name="password" value="123">
        <table>
            <tr>
                <td>姓名</td>
                <td><input type="text" name="ename"></td>
            </tr>
            <tr>
                <td>所属部门</td>
                <td><input type="text" name="dept"></td>
            </tr>
            <tr>
                <td>年龄</td>
                <td><input type="text" name="age"></td>
            </tr>
            <tr>
                <td>性别</td>
                <td><input type="text" name="gender"></td>
            </tr>
            <tr>
                <td>入职时间</td>
                <td><input type="text" name="workdate"></td>
            </tr>
            <tr>
                <td><input type="submit" value="添加"></td>
                <td><input type="button" value="返回" onclick="history.go(-1);"></td>
            </tr>
        </table>
    </form>
  </body>
</html>

list.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 
<c:set value="${pageContext.request.contextPath}" scope="page" var="ctx"></c:set>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'list.jsp' starting page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <style type="text/css">
        body{
        font-family: Microsoft Yahei, sans-serif;
        }
    </style>
  </head>

  <body>
    <div>
        <input type="button" value="查询" onclick="window.location.href='<%=path %>/userController/list.do'">
        <input type="button" value="添加" onclick="window.location.href='<%=path %>/userController/toadd.do'">
    </div>
    <table>
        <thead>
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>所属部门</th>
                <th>年龄</th>
                <th>性别</th>
                <th>入职时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <c:forEach items="${users}" var="item" varStatus="status">
                <tr>
                    <td>${item.eid }</td>
                    <td>${item.ename }</td>
                    <td>${item.dept }</td>
                    <td>${item.age }</td>
                    <td>${item.gender }</td>
                    <td><fmt:formatDate value="${item.workdate }" type="both" pattern="yyyy-MM-dd"/></td>
                    <td>
                        <a href="<%=path %>/userController/toupdate.do?eid=${item.eid }">修改</a>/
                        <a href="<%=path %>/userController/delete.do?eid=${item.eid }">删除</a>
                    </td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
  </body>
</html>

update.jsp

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'update.jsp' starting page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  </head>

  <body>
     <form action="<%=path %>/userController/update.do" method="post">
        <input type="hidden" name="password" value="${users.password }">
        <input type="hidden" name="eid" value="${users.eid }">
        <table>
            <tr>
                <td>姓名</td>
                <td><input type="text" name="ename" value="${users.ename }"></td>
            </tr>
            <tr>
                <td>所属部门</td>
                <td><input type="text" name="dept" value="${users.dept }"></td>
            </tr>
            <tr>
                <td>年龄</td>
                <td><input type="text" name="age" value="${users.age }"></td>
            </tr>
            <tr>
                <td>性别</td>
                <td><input type="text" name="gender" value="${users.gender }"></td>
            </tr>
            <tr>
                <td>入职时间</td>
                <td>
                    <fmt:formatDate var="newdate" value="${users.workdate}" pattern="yyyy-MM-dd"/>
                    <input type="text" name="workdate" value="${newdate }">
                </td>
            </tr>
            <tr>
                <td><input type="submit" value="修改"></td>
                <td><input type="button" value="返回" onclick="history.go(-1);"></td>
            </tr>
        </table>
    </form>
  </body>
</html>

框架搭建结束!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值