springmvc+form表单一些问题

Q:springmvc在controller层写了添加接口,在jsp页面写了submit后调转不过去指定页面,而且数据库中也没有成功加进去数据。

A:检查form后的acion对于的映射是否正确,可以用postman调用试试,有时候需要加上项目名的前缀

Q:控制层返回modelAndView前台jsp页面如何获取?

A:伪代码如下

控制层

@RequestMapping(value="/getAll', method= RequestMethod.GET)

public ModelAndView getAll(){

   List<User>  listUser = userService.getAll();

   ModelAndView mad= new ModelAndView("list", "messge" ,listUser );

   return mad;

}

页面端:

<body>

             <form action="/getAll" method="get">

            messge:${requestScope.messge}

            </form>

</body>

Q:插入数据出现乱码问题?

A:在mybatis连接的地方加上?useUnicode=true&characterEncoding=utf-8

猜你喜欢

转载自blog.csdn.net/yuyeqianhen/article/details/89882507