gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 09:01:19 27 4
gpt4 key购买 nike

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

我正在使用图块,并且我相信这个项目将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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com