发表于: 2017-09-19 20:51:22
1 673
今天完成的事情:
完成了jsp——后端——控制器的交互,使用postman测试端口使用的方法
明天计划的事情:
完成所有端口,提交任务2
遇到的问题:
1.解决了昨天连接数据库的异常
解决方法,读了下日志,使用软件翻译了一下,发现是时区问题,百度下解决了,在jdbc.url后加入
&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
也就是
jdbc.url=jdbc:mysql://localhost:3306/user?characterEncoding=utf8&useSSL=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
2.使用post方法时,提示405错误
@RequestMapping(value = "/users",method = RequestMethod.POST)
public ModelAndView register(HttpServletRequest request) throws IOException {
User user = new User();
user.setUsername(request.getParameter("username"));
user.setPassword(request.getParameter("password"));
user.setSex(request.getParameter("sex"));
userService.insertUser(user);
return new ModelAndView("registersuccess","username",user.getUsername());
}
HTTP ERROR 405
Problem accessing /users. Reason:
Request method 'GET' not supported
在师兄的指导下明白了,要在前面加一段get代码获取页面,而post方法是注册按钮的
@RequestMapping(value = "/users" , method = RequestMethod.GET)
public String toRegister(){
return "register";
}
收获:
1.jsp、控制端、数据库之间的数据交互
2.在控制端与如何使用post、get
3.使用postman测试端口方法
评论