
SpringMvc
91奔跑的蜗牛
这个作者很懒,什么都没留下…
展开
-
@RequestBody取POST方式的json字符串
场景:前端 json 数据请求到后端的时候,可以用@RequstBody来映射成相应的实体类,但是如果json格式太过复杂,而且我们不需要全部的数据,这时候我们就可以 后端 获取 请求的 json 数据,然后自己进行解析。前端:var json_data={ "name" : "demographics", "params" : [1 , 2, 3], ...原创 2020-04-29 15:32:11 · 1658 阅读 · 0 评论 -
SpringMvc 拦截器
简单说下步骤:1、定义一个类实现HandlerInterceptorpublic class LoginInterceptor implements HandlerInterceptor { @Value("${TT_TOKEN_KEY}") private String TT_TOKEN_KEY; @Value("${SSO_URL}") private String...原创 2019-09-18 19:59:26 · 113 阅读 · 0 评论 -
SpringMvc 图片上传处理
1、配置虚拟目录,将本地磁盘映射到tomcat目录2、springmvc.xml配置多媒体处理器 <!-- 配置多媒体处理器 --> <!-- 注意:这里id必须填写:multipartResolver --> <bean id="multipartResolver" class="org.springframework.web.multipart....原创 2019-07-27 19:28:34 · 155 阅读 · 0 评论 -
SpringMvc上传文件报错:the current request is not a multipart request
首先form表单的enctype有设置成multipart/form-data<form id="contentAddForm" class="itemForm" method="post" enctype="multipart/form-data">既然这样为何还会报the current request is not a multipart request的错误,原因在于fo...原创 2019-07-27 19:20:40 · 1612 阅读 · 0 评论 -
SpringMvc 配置处理器映射器和处理器适配器以及视图解析器
<!-- 配置处理器映射器 --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/> <!-- 配置处理器适配器--><bean class="org.springframework.web.servle...原创 2019-08-05 16:23:49 · 1616 阅读 · 0 评论 -
Spring @RequestParam 将前端参数赋值给Controller方法上的参数
@Controller@RequestMapping("/content/category")public class ContentCategoryController { @Autowired private ContentCategoryService service; @RequestMapping("/list") @ResponseBody publi...原创 2019-07-24 15:44:19 · 691 阅读 · 0 评论 -
静态资源处理器 mvc:resources
优雅REST风格的资源URL不希望带 .html 或 .do 等后缀.由于早期的Spring MVC不能很好地处理静态资源,所以在web.xml中配置DispatcherServlet的请求映射,往往使用 *.do 、 *.xhtml等方式。这就决定了请求URL必须是一个带后缀的URL,而无法采用真正的REST风格的URL。如果将DispatcherServlet请求映射配置为"/",则Spr...原创 2019-07-23 19:21:19 · 335 阅读 · 0 评论 -
No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'taotao-manager-web'
tomcat启动正常,浏览器输入http://localhost:8081/控制台报错:No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'taotao-manager-web'看下web.xml的配置 <!-- springmvc的前端控制器 --> <...原创 2019-07-16 11:08:17 · 12566 阅读 · 0 评论 -
springMVC的 url-pattern /和/*的区别
< url-pattern > / </ url-pattern > 会匹配到/springmvc这样的路径型url,不会匹配到模式为*.jsp这样的后缀型url。即:*.jsp不会进入spring的 DispatcherServlet类 。但是因为覆盖了默认的tomcat servlet,所以所有的请求会默认进入springmvc控制器。< url-patter...原创 2019-07-16 10:15:14 · 356 阅读 · 0 评论 -
Spring MVC @PathVariable注解
@RequestMapping("/user/{id}")public String test(@PathVariable("id") Integer id){ System.out.println(id); return "hello";}在@RequestMapping中请求路径,将需要传递的参数用{}括起来。通过@PathVariable("参数名称")来获取url...转载 2019-07-18 10:06:21 · 218 阅读 · 0 评论 -
SpringMvc set 报错: Translating SQLException with SQL state '42000', error code '1064'
### The error may involve com.heima.mapper.CustomerMapper.updateCustomer-Inline### The error occurred while setting parameters### SQL: update customer SET cust_name = ? cust_source...原创 2019-06-11 23:15:45 · 574 阅读 · 0 评论 -
SpringMvc @ResponseBody ajax
Controll层返回json数据,给前端的ajax前端代码: function editCustomer(id) { $.ajax({ type:"get", url:"<%=basePath%>customer/edit.action", data:{"id":id}, success:function(data) { $(...原创 2019-06-11 22:37:03 · 347 阅读 · 0 评论 -
SpringMvc 在controll层读取properties文件的属性值
背景:如上图,所属行业从数据库字典表中获取//所属行业List<BaseDict> industryType = baseDictService.queryBaseDictByDictTypeCode("001");这边的"001"存在硬编码,能否把字典表中dic_type_code类别分类的值集写在配置文件properties中,然后Controller层读取配置文件...原创 2019-05-31 10:32:09 · 1406 阅读 · 0 评论 -
jsp fmt:formatDate标签与springmvc Converter结合使用
<fmt:formatDate>标签用于使用不同的方式格式化日期。<td><input type="text" name="createtime" value="<fmt:formatDate value="${item.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>" /></td>...原创 2019-04-29 11:34:55 · 345 阅读 · 0 评论 -
Springmvc @RequestBody ajax
ajax封装的data数据,只要key跟pojo的属性一致,就会自动封装到对应的pojo。 <script type="text/javascript"> $.ajax({ type: "post", /* contentType:"application/json charset=utf-8",报错 ...原创 2019-04-28 17:58:13 · 397 阅读 · 0 评论