swagger UI 输入汉字参数传到后台后乱码

wx_lding 2017-11-18 11:06:44
...全文
1019 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
¹º月²⁴日 2018-04-24
  • 打赏
  • 举报
回复
如果你用的是tomcat的话,打开tomcat的server.xml文件,找到下面这行: <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/> 加上URIEncoding="UTF-8"即可,如果不是UTF-8可以试试别的,如:GBK,GB2312等。
it狗_ 2017-12-04
  • 打赏
  • 举报
回复
@ApiOperation("单个选中/取消选中商品")
    @RequestMapping(value = "/checkedSku",method = {RequestMethod.POST,RequestMethod.GET},produces = "application/json;charset=UTF-8")
    public RespData checkedSku(@ApiParam(value = "平台Id",required = true)@RequestParam("platformId") Long platformId){
        return respData;
    }
it狗_ 2017-12-04
  • 打赏
  • 举报
回复
@ApiOperation("单个选中/取消选中商品") @RequestMapping(value = "/checkedSku",method = {RequestMethod.POST,RequestMethod.GET},produces = "application/json;charset=UTF-8") public RespData checkedSku(@ApiParam(value = "平台Id",required = true)@RequestParam("platformId") Long platformId){ return respData; }
哩哩啦啦’ 2017-12-04
  • 打赏
  • 举报
回复
建议直接在后台接参数转一下就ok了
Sunyiban 2017-12-04
  • 打赏
  • 举报
回复
引用 4 楼 wxfwxfwxfwxf 的回复:
1.看看浏览器的编码 2.看看web.xml的配置: <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> 3.看看spring mvc的配置: <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> </bean> </list> </property> </bean>
楼上正解,如果实在不行,就在后台转码吧~
烈马狂生 2017-12-04
  • 打赏
  • 举报
回复
1.看看浏览器的编码 2.看看web.xml的配置: <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> 3.看看spring mvc的配置: <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> </bean> </list> </property> </bean>
wx_lding 2017-11-18
  • 打赏
  • 举报
回复
求大神 指点 别沉!

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧