JSP中没有填充Struts2属性

时间:2017-03-24 14:39:56

标签: java jsp struts2 jstl ognl

我有一个没有填充任何EL或OGNL变量的Struts 2.5.10.1应用程序。我已经通过调试器验证了变量是在action类上设置的。错误是“类com.sun.proxy。$ Proxy404”没有属性'jobRunning'。 文件:javax / el / BeanELResolver.java 行号:686“。这是Struts.xml:

android:text="androidText"

该动作具有这些基于注释的拦截器:

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
        "http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
    <constant name="struts.custom.i18n.resources" value="global"/>
    <constant name="struts.enable.SlashesInActionNames" value="true"/>
    <constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
    <constant name="struts.patternMatcher" value="namedVariable"/>
    <constant name="struts.devMode" value="true"/>
    <constant name="struts.multipart.maxSize" value="16777216"/>
    <constant name="struts.convention.default.parent.package" value="parent-package"/>
    <constant name="struts.enable.DynamicMethodInvocation" value="true"/>
    <constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>
    <constant name="struts.objectFactory.spring.autoWire.alwaysRespect" value="true"/>


    <package name="parent-package" extends="security-manager,struts2-support,json-default" namespace="/">

    </package>
</struts>

jsp标题:

@InterceptorRefs({
        @InterceptorRef(value = "exception"),
        @InterceptorRef(value = "alias"),
        @InterceptorRef(value = "servletConfig"),
        @InterceptorRef(value = "i18n"),
        @InterceptorRef(value = "userInfoObjectInterceptor"),
        @InterceptorRef(value = "securityCheckInterceptor", params = {"mode", "before"}),
        @InterceptorRef(value = "prepare"),
        @InterceptorRef(value = "debugging"),
        @InterceptorRef(value = "fileUpload"),
        @InterceptorRef(value = "checkbox"),
        @InterceptorRef(value = "multiselect"),

        @InterceptorRef(value = "staticParams"),
        @InterceptorRef(value = "actionMappingParams"),
        @InterceptorRef(value = "params", params = {"excludeParams", "dojo\\..*,^struts\\..*", "ordered", "true"}),
        @InterceptorRef(value = "securityCheckInterceptor", params = {"mode", "after"}),
        @InterceptorRef(value = "validation", params = {"validateAnnotatedMethodOnly", "true"}),
        @InterceptorRef(value = "workflow")
})

失败点:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="app" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/dateFormat.js"></script>

<%--@elvariable id="action" type="njob.actions.WelcomeAction"--%>

<app:wrapper pageTitle="Welcome Page">
<jsp:body>

动作类具有正确的getter和setter:

<c:out value="${action.currentEnvironment}"/> <%-- also fails with <s:property value="%{currentEnvironment}--%>

1 个答案:

答案 0 :(得分:0)

好的,我发现如何强制创建基于CGLIB的代理来执行操作。我将此行添加到applicationContext.xml:

<aop:aspectj-autoproxy proxy-target-class="true"/>

我仍然不知道为什么Struts使用了错误的代理类。我的应用程序甚至没有使用Spring AOP库。我认为这与我公司的自定义struts插件有关。

相关问题