spring - 带有Tiles的Struts/Spring错误页面

标签 spring error-handling internationalization struts tiles

我仍然是新手,我不确定如何实现自定义错误页面。

我正在使用图块,并且我相信这个项目将struts2和spring框架整合在一起。

我在web.xml中做了一些基本的工作:

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

完美无缺-只要我对图块的所有部分进行硬编码并且不使用i18n。一旦我放置:
<s:text name="404.error.title" />

它得到错误:

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? 100多个代码中没有servlet-thing。
很多struts.xml和appContext.xml的东西。我不确定该怎么办。

而且我不想在我的所有jsps中放入大量错误页面标签。

但是,实际上,我只想知道是否有一种方法可以使整个站点范围的错误页面定向到操作/平铺页面。类似于上面的代码。

非常感谢。

最佳答案

您需要在web.xml中配置Struts2 FilterDispatcher。这是一个示例配置:

<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>

关于spring - 带有Tiles的Struts/Spring错误页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1032761/

相关文章:

objective-c - 标准化错误代码-Objective-C

python - 调用函数时,try/except语句在哪里?

angularjs - angularjs过滤'date'和$ locale服务

java - Jersey Rest 服务具有 HTTP 基本安全性,不接受用户

java - 寻找Spring 3.0中更简洁的JSP转发配置

spring - 如何在不读取重叠数据的情况下在 spring batch 中运行并发作业

Django:在不使用语言 session /cookie的情况下翻译字符串

java - 尽管有 'DB_CLOSE_ON_EXIT=FALSE',但 H2 内存中测试数据库已关闭

java - 切换案例错误验证

grails - grails 中 CONTENT i18n 的良好实践有哪些