web
开始搓邪恶的前端页面小程序,加油!
web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> <!--spring--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring.xml</param-value> </context-param> <!--过滤器--> <filter> <filter-name>charset</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>charset</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!--监听器--> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!--serlvet--> <servlet> <servlet-name>spring</servlet-name> <!--拦截下来的请求,依据相应的规则分发到目标Controller来处理--> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring.xml</param-value> </init-param> </servlet> <servlet-mapping> <!--截获请求,将符合*.do格式的资源的请求都由指定的servlet处理--> <servlet-name>spring</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>
index.jsp
留意这里注释掉的地方,掌握这些小技巧,40分钟不是梦!
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%-- Created by IntelliJ IDEA. User: mu_bai Date: 2019/11/13 Time: 22:12 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %> <html> <head> <title>Title</title> </head> <body> <%--div.header>a[href='save.jsp']{创建新用户} 打完按tab键,感受快乐--%> <div class="header"><a href="save.jsp">创建新用户</a></div> <%--div.ctx>table.table>(tr>th*4)+(tr>td*4)--%> <div class="ctx"> <table class="table"> <tr> <th>用户编号</th> <th>用户姓名</th> <th>用户生日</th> <th>用户操作</th> </tr> <c:forEach items="${infos}" var="us"> <tr> <td>${us.userid}</td> <td>${us.username}</td> <td>${us.birthday}</td> <td> <%--a[href='single.do?userid=']{修改}*2--%> <a href="single.do?userid=${us.userid}">修改</a> <a href="del.do?userid=${us.userid}">删除</a> </td> </tr> </c:forEach> </table> </div> </body> </html>
save.jsp
<%-- Created by IntelliJ IDEA. User: mu_bai Date: 2019/11/13 Time: 22:27 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body> <%--div.ctx>form[action='save.do' method='post']>(label{用户}+input[type='text' name='']+br)*3--%> <div class="ctx"> <form action="save.do" method="post"> <label>用户姓名</label> <input type="text" name="username"><br> <label>用户生日</label> <input type="date" name="birthday"><br> <input type="submit" value="提交用户"><br> </form> </div> </body> </html>
user.jsp
<%-- Created by IntelliJ IDEA. User: mu_bai Date: 2019/11/13 Time: 23:19 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false"%> <html> <head> <title>Title</title> </head> <body> <div class="ctx"> <form action="mod.do" method="post"> <input type="hidden" name="userid" value="${user.userid}"> <label>用户姓名</label> <input type="text" name="username" value="${user.username}"><br> <label>用户生日</label> <input type="date" name="birthday" value="${user.birthday}"><br> <label>用户</label> <input type="submit" value="修改用户"><br> </form> </div> </body> </html>
最后
部署Tomcat
35分钟,一套用SSM框架轻轻松松完成的CURD打完收功!!