views:

992

answers:

2

I'm still a newbie, and I'm not sure how else to implement custom error pages.

I'm using tiles, and I believe this project has the struts2 and spring framework mangled together.

I did the basic stuff in my web.xml:

<error-page>
    <error-code>404</error-code>
    <location>/WEB-INF/jsps/404error.jsp</location>
</error-page>

Works perfect - so long as I hard-code all the parts of the tiles and don't use i18n. As soon as I place a:

<s:text name="404.error.title" />

It gets the error:

The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]

Servlet? There are no servlets-things in the 100+ code lying around. Lots of struts.xml and appContext.xml stuff. I'm not sure what to do.

And I don't want to put tons of errorpage tags in all my jsps.

But really, I just want to know if there is a way to make a site-wide error-page that directs to an action/tile page. Like the < error-page > code above.

Thanks a lot.

A: 

You need to have the Struts2 FilterDispatcher configured in your web.xml. Here is an example configuration:

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>
     org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
Rich Kroll
Thanks so much. I didn't realize the difference in the tons of existing filters...
Glad it helped! If this worked for you, please accept/close the question so others know this is the correct and can search on it.
Rich Kroll
Hm... Actually I was too quick to decide it would work...I tried using both struts2 filters and commenting out the previous struts2 filter, but it seems to have no effect.<filter-name>struts2-old</filter-name><filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>Still the same servlet error...
Also... how do you close a question? Not sure where to click.Thanks!
A: 

thanks for the info...

javagenious