分布式restful中的问题

1、 访问服务后返回值中有中文乱码

在RequestMapping中添加produces属性。

@RequestMapping(value = "/user/register", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE + ";charset=utf-8")

如果返回是json的场合,APPLICATION_JSON_VALUE

2、 put类型请求无法获取参数

在web.xml中添加对于过滤器

<filter>

<filter-name>HttpMethodFilter</filter-name>

<filter-class>org.springframework.web.filter.HttpPutFormContentFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>HttpMethodFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

注意:

需要注意的是,该过滤器只能接受enctype值为application/x-www-form-urlencoded的表单,也就是说,在使用该过滤器时,form表单的代码必须如下:

<form action="" method="put" enctype="application/x-www-form-urlencoded">  

......  

</form>  

posted @ 2019-01-27 12:56  mollie_x  阅读(243)  评论(0编辑  收藏  举报