java - calling spring controller from web.xml (exception-type) -


i need know if way there call spring controller web.xml following location:

<error-page>     <exception-type>org.demo.exceptions.invalidsessionexception</exception-type>     <location>/login.jsp</location> </error-page> 

i have created custom exception class named invalisessionexception, typically call jsp page <location> tag, need call login controller such auth/login i.e. <location>/auth/login</location>.

is there way achieve ?

invalisessionexception.java

public class invalidsessionexception extends nullpointerexception  {     private static final long serialversionuid = 1l;  public string getmessage() {     return "no user logged in."; }  public int getexceptiontype() {     return -1; } } 

the preferred way add "global exception handler" within in spring context, instead of trying re-enter spring context web.xml.

you can achieve configuring org.springframework.web.servlet.handler.simplemappingexceptionresolver bean in context. set exceptionmappings property list of exceptions resolver should act on, , each exception, mention view should shown user.

this keeps design clean , maintainable.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -