如何在Spring MVC拦截器中访问Request参数

时间:2014-10-23 07:55:19

标签: jquery spring spring-mvc

我正在使用Spring MVC Interceptor,即实现“HandlerInterceptor”。

在我的preHandle方法中如何获取从浏览器传递的Request参数?我们需要根据浏览器的请求输入进行预处理

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    request.getParameter("myData") // this is returning null        
}

使用jquery post request

从前端传递数据
var rq = 'myData:{"custDetails":{"CustId":"123456"}}';
$.ajax({
        url : "myhost/TestController/testMethod",
        type : "POST",
        dataType : "json",
        beforeSend : function(xhr) {
                xhr.setRequestHeader("Content-type", "application/json");
        },
        data : rq,
        success : function(data) {
                if (data.status == false)
                        //location.href = "failure.html";
                else
                        $('#result').html(data.test.msg);
        },
        error : function(data) {

        }

我能够获取请求标题详细信息,因为不是参数详细信息我在做任何错误请咨询吗?

0 个答案:

没有答案