摘要: 在Controller的ajax方法上添加@ResponseBody @ResopnseBody作用: 1.把java字符串转换为json @RequestMapping("Ajax1") @ResponseBody public String ajax(String name) { System. 阅读全文
posted @ 2019-09-03 22:03 kfsrex 阅读(261) 评论(0) 推荐(0) 编辑
摘要: @RequestMapping("login") public ModelAndView login(User user,ModelAndView mv,HttpSession session) { System.out.println(user); mv.setViewName("redirect 阅读全文
posted @ 2019-09-03 22:02 kfsrex 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 当在web.xml中配置DispatcherServlet时的url-pattern的值为 / 这样会拦截所有,静态资源不会放行。 释放静态资源:在springMVC配置文件里添加<mvc:default-servlett-handler/> <?xml version="1.0" encoding 阅读全文
posted @ 2019-09-03 22:02 kfsrex 阅读(553) 评论(0) 推荐(0) 编辑
摘要: 1.接收简单参数,在Controller的方法后面添加相应的参数列表,Controller的参数列表要和view层传的参数名一致。 2.接收对象参数,在Controller的方法后面添加相应的实体类,实体类的属性名要和view层传的参数名一致。 Controller类 package com.zhi 阅读全文
posted @ 2019-09-03 22:01 kfsrex 阅读(438) 评论(0) 推荐(0) 编辑
摘要: 1.把数据保存到request中,(在Controller方法后添加Map来创建Map) a) 保存到HttpServletRequest中 b) 保存到ModelAndView中,返回类型只能是ModelAndView c) 保存到Map中 2.把数据保存到session中 a) 保存到HttpS 阅读全文
posted @ 2019-09-03 22:01 kfsrex 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 1.默认的BeanNameUrlHandlerMapping(通过name查找Controller)用Controller的name来访问 2.ControllerClassNameHandlerMapping(通过Controller类的名字查找Controller。在网页访问除了Controll 阅读全文
posted @ 2019-09-03 21:59 kfsrex 阅读(456) 评论(0) 推荐(0) 编辑
摘要: <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <!—初始化传入的参数 -- 阅读全文
posted @ 2019-09-03 21:59 kfsrex 阅读(411) 评论(0) 推荐(0) 编辑
摘要: 1.导入需要的jar包 a) spring-beans b) spring-context c) spring-core d) spring-expression e) spring-web f) spring-webmvc g) commons-logging(日志包) 2.在web.xml中配置 阅读全文
posted @ 2019-09-03 21:57 kfsrex 阅读(213) 评论(0) 推荐(0) 编辑
摘要: SpringMVC mvc、SSM,springMVC思路图 m:Model(dao和bean) v:View(jsp、php、excel、pdf...) c:Controller(servlet) S:spring() S:springMVC(接收数据并完成数据的封装,页面的跳转逻辑) M:myb 阅读全文
posted @ 2019-09-03 21:56 kfsrex 阅读(340) 评论(0) 推荐(0) 编辑
摘要: 在映射文件里insert标签内添加keyProperty属性和userGeneratedKeys属性 <!-- 添加用户并返回主键值 --> <!-- keyProperty:把主键值放在对于实体类属性里 userGeneratedKeys:表示是否生成主键 --> <insert id="inse 阅读全文
posted @ 2019-08-31 20:52 kfsrex 阅读(676) 评论(0) 推荐(0) 编辑