javax.servlet.ServletException: 请求[/平台] 不包含名为 'action' 的处理程序参数
javax.servlet.ServletException: Request[/platform] does not contain handler parameter named 'action'
我在开发 Struts 软件。软件 运行 正确,但是当我停留超过 5 分钟无所事事并点击加入另一个页面时,我收到错误 500 :
javax.servlet.ServletException: Request[/platform] does
not contain handler parameter named 'action'.
我和我的公司谈过,问题不可能出在服务器安全上。
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-ref>
<res-ref-name>jdbc/GenLicenseDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>content</param-name>
<param-value>utf8</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>6</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>convertNull</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<listener>
<listener-class>fr.niji.struts.utils.Starter</listener-class>
</listener>
<welcome-file-list id="WelcomeFileList">
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jws</welcome-file>
</welcome-file-list>
</web-app>
STRUTS-CONFIG.XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="platformForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="action" type="java.lang.String" />
<form-property name="idPlatform" type="java.lang.String" />
<form-property name="platformName" type="java.lang.String" />
<form-property name="idVersion" type="java.lang.String" />
<form-property name="idLicense" type="java.lang.String" />
<form-property name="description" type="java.lang.String" />
</form-bean>
<form-bean name="versionForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="action" type="java.lang.String" />
<form-property name="idVersion" type="java.lang.String" />
<form-property name="compareVersion" type="java.lang.String" />
<form-property name="versionName" type="java.lang.String" />
<form-property name="versionList" type="java.util.List" />
<form-property name="versionFile" type="org.apache.struts.upload.FormFile" />
</form-bean>
<form-bean name="licenseForm" type="fr.niji.struts.form.LicenseForm" />
<form-bean name="equipmentsForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="action" type="java.lang.String" />
<form-property name="equipmentsList" type="java.util.List" />
<form-property name="equipmentsFile" type="org.apache.struts.upload.FormFile" />
</form-bean>
</form-beans>
<global-exceptions>
<exception key="unauthorized" type="fr.niji.exception.UnauthorizedException"
path="/login.do" />
</global-exceptions>
<global-forwards>
<forward name="logOff" path="/sessionexpired.do?action=execute" />
<forward name="MENU_LOGOFF" path="/logout.do" />
</global-forwards>
<action-mappings>
<action path="/UnCaughtFatalErrorAction" type="fr.niji.struts.action.UnCaughtFatalErrorAction">
<forward name="backToLogin" path="/login.jsp"></forward>
</action>
<action path="/sessionexpired" type="fr.niji.struts.action.SessionExpiredAction">
<forward name="logoff" path="/login.jsp"></forward>
</action>
<!-- login action -->
<action attribute="loginForm" input="/form/login.jsp" name="loginForm"
path="/login" scope="request" type="fr.niji.struts.action.LoginAction">
<forward name="login_ko" path="/login.jsp" />
<forward name="login_ok" path="/imput.do?action=init" />
</action>
<action attribute="platformForm" name="platformForm" path="/platform"
scope="request" parameter="action" type="fr.niji.struts.action.PlatformAction">
<forward name="list" path="/listPlatforms.jsp" />
<forward name="display" path="/displayPlatform.jsp" />
<forward name="change" path="/displayPlatform.jsp" />
</action>
<action attribute="versionForm" name="versionForm" path="/version"
scope="request" parameter="action" type="fr.niji.struts.action.VersionAction">
<forward name="list" path="/listVersions.jsp" />
<forward name="display" path="/displayVersion.jsp" />
<forward name="add" path="/addVersion.jsp" />
</action>
<action attribute="licenseForm" name="licenseForm" path="/license"
scope="request" parameter="action" type="fr.niji.struts.action.LicenseAction">
<forward name="display" path="/displayLicense.jsp" />
<forward name="add" path="/addLicense.jsp" />
</action>
<action attribute="equipmentsForm" name="equipmentsForm"
path="/equipments" scope="request" parameter="action"
type="fr.niji.struts.action.EquipmentsAction">
<forward name="display" path="/displayEquipments.jsp" />
</action>
<!-- logout action -->
<action attribute="logoutForm" input="/index.jsp" name="logoutForm"
path="/logout" scope="request" type="fr.niji.struts.action.LogoutAction">
<forward name="logout" path="/logoff.jsp" />
</action>
</action-mappings>
<message-resources parameter="fr.niji.configuration.ApplicationResources"
null="false" />
</struts-config>
Error 500 : javax.servlet.ServletException: Request[/platform] does not contain handler parameter named 'action'.
您正在调用映射为 /platform
的操作,它需要一个名为 action
的参数。您应该将参数 action
添加到 URL.
<action attribute="platformForm" name="platformForm" path="/platform"
scope="request" parameter="action" type="fr.niji.struts.action.PlatformAction">
<forward name="list" path="/listPlatforms.jsp" />
<forward name="display" path="/displayPlatform.jsp" />
<forward name="change" path="/displayPlatform.jsp" />
</action>
千辛万苦后,我找到了解决办法。为了修改 URL,我继续我的 jsp 并修改标签 html:form
。
例如,使用操作参数“添加”:
<html:form action="/platform.do?action=add" styleId="formPrincipale"> <html:hidden property="idPlatform" styleId="idPlatform"/> <html:hidden property="action" styleId="action" value="add"/>
我在开发 Struts 软件。软件 运行 正确,但是当我停留超过 5 分钟无所事事并点击加入另一个页面时,我收到错误 500 :
javax.servlet.ServletException: Request[/platform] does not contain handler parameter named 'action'.
我和我的公司谈过,问题不可能出在服务器安全上。
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<resource-ref>
<res-ref-name>jdbc/GenLicenseDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>content</param-name>
<param-value>utf8</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>6</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>convertNull</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<listener>
<listener-class>fr.niji.struts.utils.Starter</listener-class>
</listener>
<welcome-file-list id="WelcomeFileList">
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jws</welcome-file>
</welcome-file-list>
</web-app>
STRUTS-CONFIG.XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<data-sources />
<form-beans>
<form-bean name="platformForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="action" type="java.lang.String" />
<form-property name="idPlatform" type="java.lang.String" />
<form-property name="platformName" type="java.lang.String" />
<form-property name="idVersion" type="java.lang.String" />
<form-property name="idLicense" type="java.lang.String" />
<form-property name="description" type="java.lang.String" />
</form-bean>
<form-bean name="versionForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="action" type="java.lang.String" />
<form-property name="idVersion" type="java.lang.String" />
<form-property name="compareVersion" type="java.lang.String" />
<form-property name="versionName" type="java.lang.String" />
<form-property name="versionList" type="java.util.List" />
<form-property name="versionFile" type="org.apache.struts.upload.FormFile" />
</form-bean>
<form-bean name="licenseForm" type="fr.niji.struts.form.LicenseForm" />
<form-bean name="equipmentsForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="action" type="java.lang.String" />
<form-property name="equipmentsList" type="java.util.List" />
<form-property name="equipmentsFile" type="org.apache.struts.upload.FormFile" />
</form-bean>
</form-beans>
<global-exceptions>
<exception key="unauthorized" type="fr.niji.exception.UnauthorizedException"
path="/login.do" />
</global-exceptions>
<global-forwards>
<forward name="logOff" path="/sessionexpired.do?action=execute" />
<forward name="MENU_LOGOFF" path="/logout.do" />
</global-forwards>
<action-mappings>
<action path="/UnCaughtFatalErrorAction" type="fr.niji.struts.action.UnCaughtFatalErrorAction">
<forward name="backToLogin" path="/login.jsp"></forward>
</action>
<action path="/sessionexpired" type="fr.niji.struts.action.SessionExpiredAction">
<forward name="logoff" path="/login.jsp"></forward>
</action>
<!-- login action -->
<action attribute="loginForm" input="/form/login.jsp" name="loginForm"
path="/login" scope="request" type="fr.niji.struts.action.LoginAction">
<forward name="login_ko" path="/login.jsp" />
<forward name="login_ok" path="/imput.do?action=init" />
</action>
<action attribute="platformForm" name="platformForm" path="/platform"
scope="request" parameter="action" type="fr.niji.struts.action.PlatformAction">
<forward name="list" path="/listPlatforms.jsp" />
<forward name="display" path="/displayPlatform.jsp" />
<forward name="change" path="/displayPlatform.jsp" />
</action>
<action attribute="versionForm" name="versionForm" path="/version"
scope="request" parameter="action" type="fr.niji.struts.action.VersionAction">
<forward name="list" path="/listVersions.jsp" />
<forward name="display" path="/displayVersion.jsp" />
<forward name="add" path="/addVersion.jsp" />
</action>
<action attribute="licenseForm" name="licenseForm" path="/license"
scope="request" parameter="action" type="fr.niji.struts.action.LicenseAction">
<forward name="display" path="/displayLicense.jsp" />
<forward name="add" path="/addLicense.jsp" />
</action>
<action attribute="equipmentsForm" name="equipmentsForm"
path="/equipments" scope="request" parameter="action"
type="fr.niji.struts.action.EquipmentsAction">
<forward name="display" path="/displayEquipments.jsp" />
</action>
<!-- logout action -->
<action attribute="logoutForm" input="/index.jsp" name="logoutForm"
path="/logout" scope="request" type="fr.niji.struts.action.LogoutAction">
<forward name="logout" path="/logoff.jsp" />
</action>
</action-mappings>
<message-resources parameter="fr.niji.configuration.ApplicationResources"
null="false" />
</struts-config>
Error 500 : javax.servlet.ServletException: Request[/platform] does not contain handler parameter named 'action'.
您正在调用映射为 /platform
的操作,它需要一个名为 action
的参数。您应该将参数 action
添加到 URL.
<action attribute="platformForm" name="platformForm" path="/platform"
scope="request" parameter="action" type="fr.niji.struts.action.PlatformAction">
<forward name="list" path="/listPlatforms.jsp" />
<forward name="display" path="/displayPlatform.jsp" />
<forward name="change" path="/displayPlatform.jsp" />
</action>
千辛万苦后,我找到了解决办法。为了修改 URL,我继续我的 jsp 并修改标签 html:form
。
例如,使用操作参数“添加”:
<html:form action="/platform.do?action=add" styleId="formPrincipale"> <html:hidden property="idPlatform" styleId="idPlatform"/> <html:hidden property="action" styleId="action" value="add"/>