0

I need help on this, please take a look at my code:

@ControllerAdvice
@EnableWebMvc
public class GlobalExceptionController {

    @ExceptionHandler(CustomGenericException.class)
    public ModelAndView handleCustomException(CustomGenericException ex) {

        // create the model and view with the tiles View pointing to error jsp page
        ModelAndView model = new ModelAndView("pagina.erro");
        model.addObject("errCode", ex.getErrCode());
        model.addObject("errMsg", ex.getErrMsg());

        return model;

    }
...

Tiles configuration:

<definition name="pagina.erro" extends="baseLayout">
    <put-attribute name="titlepagina" value="Página de Erro" />
    <put-attribute name="body" value="/WEB-INF/jsp/error/erro-generico.jsp" />
</definition>

In my Spring configuration xml I have:

<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix">
        <value>/WEB-INF/jsp/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean>

The page erro-generico.jsp is being loaded because if I put a wrong code in it errors will be shown on eclipse console.

The problem is: the page is not shwowing, the actual page keeps showing on the browser, not even the URL changes.

What could be wrong?

Francisco Souza
  • 806
  • 15
  • 38
  • is the exception handler getting hit, could you post the server logs? – Angular University Feb 20 '14 at 19:46
  • Yes, the code for the exception handler is being hit and the page is beeing lunched, but not showing, there is nothing on console, the only thing I see is: Fev 20, 2014 5:18:26 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar Informações: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. – Francisco Souza Feb 20 '14 at 20:15

1 Answers1

0

The problem is that the view resolver being used is not compatible with Tiles, it only works for pure JSPs.

It's possible to configure a view resolver for Tiles by following these instructions - 14.3.2. How to integrate Tiles:

bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
  <property name="definitions">
    <list>
      <value>/WEB-INF/defs/general.xml</value>
      <value>/WEB-INF/defs/widgets.xml</value>
      <value>/WEB-INF/defs/administrator.xml</value>
      <value>/WEB-INF/defs/customer.xml</value>
      <value>/WEB-INF/defs/templates.xml</value>
    </list>
  </property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
  <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
Angular University
  • 42,341
  • 15
  • 74
  • 81