我正在尝试使用 bean 来显示预定义消息,我创建了以下文件,但是当我输入
< me
时,它遇到以下错误,自动代码生成器不显示 <message - resources>
标签!!!!
org.apache.jasper.JasperException: 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]
root cause
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]
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.2.2 logs.
struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts-config>
<!-- Configuration for the default package. -->
<message-resources parameter="com/myapp/struts/messages"/>
<package name="default" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>
<action name="register">
<result type="tiles">register</result>
</action>
</package>
</struts-config>
register.jsp
:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<div id="Header">
<bean:message key="welcome.loggedin"/>
</div>
messages.properties
:
# -- welcome --
welcome.loggedin=You are logged in.
welcome.heading=Struts Applications in Netbeans!
welcome.message=It's easy to create Struts applications with NetBeans.
我想问题出在我的 jar 文件上
commons-digester-1.8.1.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-lang-2.1.jar
commons-logging-1.1.jar
displaytag-1.2.jar
displaytag-export-poi-1.2.jar
displaytag-portlet-1.2.jar
freemarker-2.3.13.jar
jdom-1.1.jar
jstl-1.2.jar
junit-3.8.1.jar
ognl-2.6.11.jar
pagertag.jar
sqlite-jdbc-3.7.2.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.1.6.jar
struts2-dojo-plugin-2.1.2.jar
struts2-tiles-plugin-2.1.6.jar
tiles-api-2.1.2.jar
tiles-compat-2.1.2.jar
tiles-core-2.1.2.jar
tiles-jsp-2.1.2.jar
tiles-servlet-2.1.2.jar
struts-taglib-1.3.10.jar
xwork-2.1.2.jar
<bean:message key=
标签是一个Struts1标签,在Struts2中它被替换为<s:text name=
。除非您没有足够的理由运行这两个框架,否则您不应该使用 Struts1 标签。
您在 Struts 2 应用程序中使用 Struts 1 标签。不。 Struts 1 和 Struts 2 是两个完全不同的 Web 框架。
这里是关于 i18n 的 Struts2 文档页面。