一尘不染

上传到服务器后,页面上只有一个getter

jsp

我有一个在Struts2框架上工作的网站。它在我的本地计算机上可以正常工作,但是当我将其上传到远程服务器(托管)时,一些吸气剂和吸气剂就不再呼唤。例如:

动作:ForecastAction.java

JSP:Forecast.jsp

这是Forecast.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
...
 <span><s:property value="day" /></span>
 <span><s:property value="month" /></span>
 <span class="week_day"><s:property value="weekday" /></span>
 ...

这是 ForecastAction.java

public class ForecastAction extends ActionSupport {

    private  String day, month, weekday;
    ... (other variables)

    public String getDay() {
        System.out.println("Ask for day");
        return day;
    }

    public void setDay(String day) {
        this.day = day;
    }

    public String getMonth() {
        System.out.println("Ask for month");
        return month;
    }

    public void setMonth(String month) {
        this.month = month;
    }

    public String getWeekday() {
        return weekday;
    }

    public void setWeekday(String weekday) {
        this.weekday = weekday;
    }
    ... (other setters and getters)
    public String execute(){
            ... (calculcating parameters)
            return SUCCESS;
    }
}

在我的本地计算机上,我可以看到所有值(日,月和周日),但是远程服务器仅返回jsp的日值。我认为这些属性之间没有区别,但支撑仅显示一天。我已经检查过,该操作(在远程服务器上)会计算所有值,因此变量不是空的。问题在于吸气剂不是由支撑杆来调用的。

在我的应用程序的其他操作中也观察到了相同的问题:setter
setPassword()不起作用,但setLogin()在授权操作中效果很好。(它只有两个二传手)。

UPD:

当我像这样在jsp中更改日期和月份时:

<span><s:property value="%{#day}"/></span>
<span><s:property value="%{#month}"/></span>

我开始正确地看到工作日。似乎,支柱只显示出他喜欢的第一属性:)再也没有。

JSP Debug:
Struts has detected an unhandled exception:
1.permission can't be null

2.actionErrors

3.Caught an exception while getting the property values of Weather.Action.Public.ForecastAction@749f6da7

4.An exception occurred processing JSP page /forecast.jsp at line 3 1: <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2: <%@ taglib prefix="s" uri="/struts-tags" %> 3: 4: 5: 6: Stacktrace:

Stacktraces

org.apache.jasper.JasperException: An exception occurred processing JSP page /forecast.jsp at line 3 1: <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2: <%@ taglib prefix="s" uri="/struts-tags" %> 3: 4: 5: 6: Stacktrace:
  1)Caught an exception while getting the property values of  Weather.Action.Public.ForecastAction@30aa119a - Class: ognl.ObjectPropertyAccessor File: ObjectPropertyAccessor.java Method: getPossibleProperty Line: 69 - ognl/ObjectPropertyAccessor.java:69:-1
      2)actionErrors - Class: ognl.ObjectPropertyAccessor File:                ObjectPropertyAccessor.java Method: getPossibleProperty Line: 69 - ognl/ObjectPropertyAccessor.java:69:-1
         3)ognl.OgnlException: actionErrors [java.lang.NullPointerException: permission can't be null]
             4)java.lang.NullPointerException: permission can't be null

/ UDP

您能帮我吗,有什么问题吗?

可能需要下一个文件:

这是我的 struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.devMode" value="true" />
<constant name="struts.multipart.maxSize" value="30000000" />

<package name="public" namespace="/" extends="struts-default">
... (other actions)
    <action name="forecast" class="Weather.Action.Public.ForecastAction" method="execute">
        <result name="success">/forecast.jsp</result>
        <result name="error">/Error.jsp</result>
    </action>
... (other actions)
</package>
...(other package)
</struts>

和web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Weather</display-name>
<welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
</welcome-file-list>

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter- class>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
    <servlet-name>StartTimerServlet</servlet-name>
    <display-name>StartTimerServlet</display-name>
    <servlet-class>Weather.Service.StartTimerServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
</servlet>

</web-app>

阅读 240

收藏
2020-06-10

共1个答案

一尘不染

它可能是Struts 2.3.1.1中的错误。和OGNL 3.0.3以及启用Java安全性的某些应用程序服务器

请参阅

https://issues.apache.org/jira/browse/OGNL-176

https://issues.apache.org/jira/browse/WW-3746

我建议您将支撑升级到最新版本

2020-06-10