升级到struts 2.3.15.1

时间:2015-12-15 15:39:53

标签: java struts2 ognl

2.2.1.1 [Struts S2-016]升级到struts 2.3.15.1 之后

    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-core</artifactId>
        <version>2.3.15.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-junit-plugin</artifactId>
        <version>2.3.15.1</version>
        <exclusions>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </exclusion>
        </exclusions>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.struts.xwork</groupId>
        <artifactId>xwork-core</artifactId>
        <version>2.3.15.1</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.apache.struts</groupId>
        <artifactId>struts2-spring-plugin</artifactId>
        <version>2.3.15.1</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

我的应用程序无法正常启动并出现多个错误!!!!

StandardContext.filterStart : Exception starting filter struts2
java.lang.NoSuchMethodError: ognl.SimpleNode.isEvalChain(Lognl/OgnlContext;)Z

经过我的调查后,我似乎也应该更改 ognl 版本

<dependency>
            <groupId>ognl</groupId>
            <artifactId>ognl</artifactId>
            <version>3.0</version>
        </dependency>

<dependency>
            <groupId>ognl</groupId>
            <artifactId>ognl</artifactId>
            <version>3.0.4</version>
        </dependency> 

在我访问登录页面时出现此错误之前,每件事情似乎都很完美

ApplicationDispatcher.invoke : Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'locale': The requested list key 'languages' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
        at org.apache.struts2.components.Component.fieldError(Component.java:240)

似乎struts不再能够识别完美的语言列表!!!

<action name="Login" class="LoginAction">
            <result name="input">/LoginForm.jsp</result>
            <result name="success" type="redirect">FillMe.do</result>
        </action>

Jsp页面

<form id="LoginForm" class="c2" method="post" action="Login.do">
        <div class="c1">
            <label for="login"><s:text name="Users.Login"/> :</label>
            <input type="text" id="login" name="login" maxlength="64"/>
        </div>
        <div class="c1">
            <label for="password"><s:text name="Users.Password"/> :</label>
            <input type="password" id="password" name="password" maxlength="64" maxlength="32"/>
        </div>
        <div class="c1">
            <label for="locale"><s:text name="Users.Language"/> :</label>
            <s:select id="locale" name="locale" list="languages" />
        </div>

    </form> 

我的清单

public Map<String, String> getLanguages() {
        LinkedHashMap<String, String> languages = new LinkedHashMap<String, String>();

            Iterator<String> it = Manager.getManager(current).getLanguagesList().iterator();
            while (it.hasNext()) {
                String lang = it.next();
                languages.put(lang, getText("Users.Language." + lang.substring(0, 2).toUpperCase()));
        }
        return languages;
    }

0 个答案:

没有答案