我在spring中开发服务,服务部署在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 BAD request”。
示例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内部。
但这些并不能解决问题。
有什么解决方案可以解决这个问题吗?提前谢谢。
发布于 2012-06-06 15:00:54
您不应允许用户自己在查询字符串中输入值。这是一种糟糕的做法,对您的web应用程序的安全性来说是非常危险的。为了避免此类攻击并限制用户篡改url,您应该在应用程序中实现HDIV框架。
一旦你实现了这一点,就没有人能篡改你的urls了。如果有人试图这样做,那么将向他们显示“错误请求”错误。
希望这对你有帮助。干杯。
https://stackoverflow.com/questions/10908969
复制相似问题