0
我在春季开发服务,服务部署在JBOSS 7.1.0中。对于请求映射 示例代码:请求参数中的特殊字符
@RequestMapping(value=/state, method=RequestMethod.GET)
public ResponseEntity<ListStatesResponseVO> getListOfStates(@RequestParam(required=false) Long id,
@RequestParam(required=false) Long page,
@RequestParam(required=false) Long pagesize);
我的问题是,当我在请求参数传递的特殊字符,它返回我一个有效的XML响应,但按照我的理解,它应该返回“400错误的请求”。
样品URI:
http://localhost:8080/location-services/location/api/state?id=$%^$^$#$%^$%
我还添加了
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/>
<property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/>
在JBoss的standalone.xml。
而且还
<filter>
<filter-name>encodingFilter</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>
<init-param>
<!-- set forceEncoding to true if you want to override encoding of servlet -->
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
web.xml中。
但是这些都没有解决问题。
是否有任何解决方案可用于此。 在此先感谢。
Thnx的答复。 – Soutrick
不客气。如果它真的帮助了你,请接受并点赞答案。 :-) –