发表于: 2018-04-25 23:03:13

1 619


今天完成的事情:

 写了根据查询姓名模糊查找到学生。

1.上午看了一上午的HTML标签,对于写出查询的jsp页面没有太多了解。

<input>标签

以及示例:(开始一直不理解数据时怎么提交到后台的)

然后自己尝试着写了一下

@ResponseBody
public List<Student> StuSelect(@RequestParam String name){
   //把姓名注入到student里
   Student student=new Student();
   student.setName(name);
   List<Student> infos = studentService.queryName(student);
   return infos;
}
//修改学生信息
@RequestMapping(value = "/editStu")
public ModelAndView editStu()throws Exception {
   //调用service层根据id查询学生信息
   Student student = studentService.queryUser(1);
   //返回modelAndView
   ModelAndView modelAndView = new ModelAndView();
   //将学生放到ModelAndView上
   modelAndView.addObject("Student",student);
   return modelAndView;
}
//显示修改成功的页面
@RequestMapping("/editStuSubmit")
public String editItemSubmit(HttpServletRequest request,Student student)throws Exception{
   studentService.updataUser(student);
   return "forward:editStu";

}

jsp页面

<form action="${pageContext.request.contextPath}/stuSelectName" method="post"></form>
<table width="100%" border=1>
   <tr>
   <td>
       <input type="text" name="name" value="${Student.name}">
   </td>
   <td><input type="submit" value="查询"/></td>
   </tr>
</table>

但是显示的时候有点问题。。

应该还是写错了。

明天计划的事情: 

专攻jsp页面的传值和跳转原理,把查询写通
遇到的问题:

jsp页面不熟悉,跳转和传值不理解。
收获:

对html标签熟悉了一些。。。


返回列表 返回列表
评论

    分享到