1

I am trying to use a bean to show predefined messages, I have created the following files, but it runs into following error, when I type < me the auto code generator does not show <message - resources> tag !!!!

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.

I suppose the problem is with my jar files

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
4

2 回答 2

2

<bean:message key=标签是一个 Struts1 标签,在 Struts2 中它被替换为<s:text name=. 除非您没有足够的理由运行这两个框架,否则您不应该使用 Struts1 标签。

于 2013-02-08T10:17:11.537 回答
1

您在 Struts 2 应用程序中使用 Struts 1 标签。不。Struts 1 和 Struts 2 是两个完全不同的 Web 框架。

这是关于 i18n 的 Struts2 文档页面

于 2013-02-08T07:09:59.317 回答