2012-01-28 31 views

Odpowiedz

16

Tak, istnieje sposób, należy złapać MissingServletRequestParameterException

Można to zrobić na kilka sposobów:

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> 

nadzieję, że pomaga.

4

Jak mogę rozwiązać mój problem:

@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");}}; 
} 
Powiązane problemy