开发者

@ResponseStatus and web.xml <error-page>

Here's what i have so far : controller :

public abstract class MyController {
   @ExceptionHandler(Exception.class)
   @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
   public void handleAllEx开发者_开发技巧ceptions(Exception e) {
      // stuff
   }
}

and my web.xml :

<error-page>
  <error-code>500</error-code>
  <location>/error.htm</location>
</error-page>

And when an unexpected exception occur, the handle works, the stuff is done, but i'm not redirect to /error.htm

Instead i'm still on the same page, but a error 500 is printed by apache.

What did i miss ?

Thanks :)


I think you need to return the view you want to show.

@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public String handleAllExceptions(Exception e) {
  return "error.jsp"; /* use the correct view name */
}

@see: Spring 3 controller exception handler implementation problems for some examples

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜