jeudi 28 mai 2015

HandlerInterceptor unable to change input params

I have a controller for setting user profile.

@RequestMapping(value = "/userProfile", method = RequestMethod.POST)
         public ModelAndView updatePersonalInfoOfEmployee( PersonalDetailsModel employeeModel,HttpServletRequest req) throws Exception{
    log.info("User profile first name "+employeeModel.getFirstName()
    }

I am using a HandlerInterceptor for handling of special characters. If a user enters a special char it should be replaced with blank string.

@Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException {
///Mehod call to remove special chars

for (Map.Entry<String, String[]> params : ((Map<String, String[]> )request.getParameterMap()).entrySet()){
                String[] values = params.getValue();
                for(int i=0;i<values.length;i++){
                    log.info("<<<<< ---------- Pre handle --------- >>>>>>>>> "+params.getKey()+" "+values[i]);
}
            }
        }

In the code above after making a call to remove special chars, I get desired request parameter. But in my controller I get the parameters with special chars.

What could be the reason?

Aucun commentaire:

Enregistrer un commentaire