Java DispatchAction ServletException:请求不包含名为“方法”的处理程序参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24028155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
DispatchAction ServletException: Request does not contain handler parameter named 'method'
提问by DavidAdair
I have searched all over and am unable to find an answer to my issue. From what I know about DispatchAction's this code should be working fine. The stack trace is as follows. I am using Struts1.3 and Spring with tiles for layouts (Please excuse my code blocks I am pretty new to using stackoverflow) Please let me know if you need more information to help me. Thanks for your time.
我已经搜索了所有内容,但无法找到我的问题的答案。根据我对 DispatchAction 的了解,这段代码应该可以正常工作。堆栈跟踪如下。我正在使用 Struts1.3 和 Spring 和用于布局的瓷砖(请原谅我的代码块,我对使用 stackoverflow 还很陌生)如果您需要更多信息来帮助我,请告诉我。谢谢你的时间。
javax.servlet.ServletException: Request[/authorizeShipment] does not contain handler parameter named 'method'. This may be caused by whitespace in the label text.
at org.apache.struts.actions.DispatchAction.unspecified(DispatchAction.java:197)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:245)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:344)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:110)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:98)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:95)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:79)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:55)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:36)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:178)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:106)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:356)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:150)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
Here are my code snippets:
这是我的代码片段:
DispatchAction:
调度动作:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.multivision.mmt.action.form.AuthorizeShipmentForm;
import com.multivision.mmt.business.ShipmentBusDelegate;
public class AuthorizeShipmentAction extends DispatchAction {
public ActionForward authorize(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
AuthorizeShipmentForm asf = (AuthorizeShipmentForm) form;
String shipmentId = asf.getShipmentId();
ShipmentBusDelegate sbd = new ShipmentBusDelegate();
try{
sbd.authorizeShipment(shipmentId);
return mapping.findForward("authorizeSuccess");
} catch(Exception ex){
System.out.println("could not approve or decline shipment");
ex.printStackTrace();
return mapping.getInputForward();
}
}
public ActionForward deny(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
AuthorizeShipmentForm asf = (AuthorizeShipmentForm) form;
String shipmentId = asf.getShipmentId();
ShipmentBusDelegate sbd = new ShipmentBusDelegate();
try{
sbd.denyShipment(shipmentId);
return mapping.findForward("authorizeDenied");
} catch(Exception ex){
System.out.println("could not approve or decline shipment");
ex.printStackTrace();
return mapping.getInputForward();
}
}
}
Here is my JSP:
这是我的 JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<html:form action="authorizeShipment.do" method="post">
<table>
<tr>
<td>AuthorizeShipment ID</td><td><html:text property="shipmentId"/></td>
</tr>
<tr>
<td><html:submit property="method" value="authorize"></html:submit></td><td><html:submit property="method" value="deny"></td>
</tr>
</table>
</html:form>
</body>
</html>
My struts-config.xml
我的 struts-config.xml
<action parameter="method" path ="/authorizeShipment" name="authorizeShipmentForm"input=".authorizeShipment" validate="false" scope="request" >
<forward name="authorizeSuccess" path=".authorizeSuccess" />
<forward name="authorizeDenied" path=".authorizeFailure" />
</action>
My action-servlet.xml
我的动作servlet.xml
<bean name="/authorizeShipment" class="com.multivision.mmt.action.AuthorizeShipmentAction"/>
采纳答案by LFF
The exception is raised because Struts cannot find a "method=xxxx" in HTTP request.
引发异常是因为 Struts 在 HTTP 请求中找不到“method=xxxx”。
I think you should change from
我认为你应该从
<html:submit parameter="method" value="deny">
to
到
<html:hidden parameter="method" value="deny"> or some other tags for hidden.
I mean, the "method=deny" should be looked as
我的意思是,“方法=拒绝”应该被视为
<input type="hidden" name="method" value="deny"/>
In your HTML pages generated from the JSP. Please check that.
在您从 JSP 生成的 HTML 页面中。请检查一下。
PS : You can use Browser Developer tool to check HTTP requests. All recent browsers can do that.
PS : 您可以使用浏览器开发工具来检查 HTTP 请求。所有最近的浏览器都可以做到这一点。