发表于: 2018-01-28 23:47:43
1 638
完成
1.在昨天的基础上成功实现了SSM框架控制器剩余的insert,update,delete。
插入:
@RequestMapping("/insert")
public String Add() {
return "add";
}
@RequestMapping("/add")
public String Add2(Student student) {
studentService.insert(student);
return "redirect:table";
}
修改
@RequestMapping("/update")
public String Edit(Integer id, Model model) {
logger.info("取ID为" + id);
Student student = studentService.selectById(id);
logger.info("查到的学生为" + student);
model.addAttribute("student", student);
return "edit";
}
@RequestMapping("/edit")
public String Edit2(Student student) {
studentService.update(student);
return "redirect:table";
}
删除
@RequestMapping("/delete")
public String Delete(Integer id) {
studentService.delete(id);
return "redirect:table";
}
add.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<form id="stuForm" action="${pageContext.request.contextPath} add" method="post">
这里不知道写什么,随便看吧
<table width="25%" border=1>
<tr>
<td>身份证号码</td>
<td><input type="text" name="id"/></td>
</tr>
<tr>
<td>你的名字</td>
<td><input type="text" name="user_name"/></td>
</tr>
<tr>
<td colspan="" align="center">
<input type="submit" value="点我提交"/></td>
</tr>
</table>
</form>
edit.jsp
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<form id="stuForm" action="${pageContext.request.contextPath} edit" method="post">
<input type="hidden" name="id" value="${student.id}"/>
修改信息
<table width="25%" border=1>
<tr>
<td>你的名字</td>
<td><input type="text" name="user_name" value="${student.user_name}"/></td>
</tr>
<tr>
<td colspan="" align="center">
<input type="submit" value="点我提交"/>
</td>
</tr>
</table>
</form>
最终页面
2.学习并安装jetty(http://blog.csdn.net/chszs/article/details/48186139)
用浏览器访问地址:http://localhost:8080/,可以看到
注意:这是我的解压地址D:\jetty-distribution-9.4.8.v20171121\demo
解压后别直接在解压文件安装,而应新建一个文件,再把解压文件放进去,然后执行java -jar start.jar。
虽然成功了,但系统有建议如下:
This instance of Jetty is not running from a separate {jetty.base} directory, this is not recommended.
暂时记录,以后再说。
问题
SSM内参数传递理解不深,还要不断回顾。
对rest风格的体会还是不深。
收获
师兄建议养成写单元测试的习惯。
计划
评论