Allen_Zsj

导航

2018年1月8日 #

SpringMVC @ModelAttribute注解

摘要: /** * @ModelAttribute标记的方法会永远最先执行 * 执行流程: * 1、执行@ModelAttribute注解修饰的方法:从数据库中去出对象,把对象放入到Map中。 * 2、SpringMVC从Map中取出User对象,并把表单的请求参数赋值给该User对象的对应属性。 * 3、 阅读全文

posted @ 2018-01-08 15:14 Allen_Zsj 阅读(125) 评论(0) 推荐(0) 编辑

表单传值给@Controller

摘要: <form action="springmvc/testModelAttributes" method="post"> <input type="hidden" name="id" value="1"/> username:<input type="text" name="username" val 阅读全文

posted @ 2018-01-08 14:50 Allen_Zsj 阅读(312) 评论(0) 推荐(0) 编辑

SpringMVC @SessionAttributes注解

摘要: @SessionAttributes 注解只能作用到类上 @SessionAttributes(value={"user"},types={String.class}) @SessionAttribututes 除了可以通过属性名制定需要放到绘画中的属性外(实际上使用的是value属性值), 还可以 阅读全文

posted @ 2018-01-08 14:15 Allen_Zsj 阅读(144) 评论(0) 推荐(0) 编辑

2017年12月21日 #

SpringMVC 如何在页面中获取到ModelAndView绑定的值

摘要: springMVC中通过ModelAndView进行后台与页面的数据交互,那么如何在页面中获取ModelAndView绑定的值呢? 1、在JSP中通过EL表达式进行获取(比较常用) 后台:ModelAndView model = new ModelAndView(); model.addObject 阅读全文

posted @ 2017-12-21 16:47 Allen_Zsj 阅读(364) 评论(0) 推荐(0) 编辑

SpringMVC ModelAndView、Map、Model、ModelMap

摘要: 目标方法返回值可以是ModelAndView 、Map、Model、ModelMap类型,但最根本还都是ModelAndView。 其中可以包含试图和模型信息。 SpringMVC 会把ModelAndView的model中数据放入到request域对象中。 ModelAndView代码示例: in 阅读全文

posted @ 2017-12-21 15:00 Allen_Zsj 阅读(116) 评论(0) 推荐(0) 编辑

SpringMVC 支持使用Servlet原生API作为目标方法的参数

摘要: 具体支持一下类型: * HttpServletRequest * HttpServletResponse * HttpSession * java.security.Pricipal * Locale * InputStream * OutputStream * Reader * Writer 代码 阅读全文

posted @ 2017-12-21 14:37 Allen_Zsj 阅读(121) 评论(0) 推荐(0) 编辑

StringMVC POJO

摘要: SpringMVC会按请求参数名和POJO类属性名进行自动匹配,自动为该属性填充属性值, 支持级联属性(本类包含其他类对象,如User类有一个属性为Address) 示例代码: index.jsp: <form action="springmvc/testPOJO" method="post"> u 阅读全文

posted @ 2017-12-21 14:19 Allen_Zsj 阅读(168) 评论(0) 推荐(0) 编辑

2017年12月20日 #

StringMVC @RequestParam属性

摘要: 1、jsp: <a href="springmvc/testRequestParam?username=allen&age=sss">test RequsetParam</a> <br/><br/> 2、Controller: @RequestMapping(value="/testRequestP 阅读全文

posted @ 2017-12-20 11:29 Allen_Zsj 阅读(172) 评论(0) 推荐(0) 编辑

Spring MVC报错:The request sent by the client was syntactically incorrect ()

摘要: 原因: 1、参数名称不一致 2、参数类型不一致 阅读全文

posted @ 2017-12-20 11:26 Allen_Zsj 阅读(89) 评论(0) 推荐(0) 编辑

SpringMVC PathVariable和post、get、put、delete请求

摘要: 1、PathVariable 可以映射URL中的占位符到目标方法的参数中。 2、Rest风格的URL 以CRUD为例: 新增:/order POST 修改:/order/id PUT 获取:/order/id GET 删除:/order/id DELETE 3、如何发送PUT和DELETE请求? 1 阅读全文

posted @ 2017-12-20 11:09 Allen_Zsj 阅读(4686) 评论(0) 推荐(0) 编辑