2012-01-28 16 views

risposta

16

Sì, c'è un modo si dovrebbe prendere MissingServletRequestParameterException

È possibile farlo in diversi modi:

1)

@ExceptionHandler(MissingServletRequestParameterException.class) 
     public String handleMyException(Exception exception) { 
     return "yourErrorViewName"; 
       } 

2)

<error-page> 
    <exception-type>org.springframework.web.bind.MissingServletRequestParameterException</exception-type> 
    <location>/WEB-INF/pages/myError.jsp</location> 
    </error-page> 

spero che aiuta.

4

Come ho risolto il mio problema:

@ResponseBody 
@ExceptionHandler(MissingServletRequestParameterException.class) 
public Object missingParamterHandler(Exception exception) { 
    // exception handle while specified arguments are not available requested service only. it handle when request is as api json service  
    return new HashMap() {{ put("result", "failed"); put("type", "required_parameter_missing");}}; 
} 
Problemi correlati