Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java DispatchAction ServletException:请求不包含名为';方法';_Java_Spring_Jsp_Struts_Tiles - Fatal编程技术网

Java DispatchAction ServletException:请求不包含名为';方法';

Java DispatchAction ServletException:请求不包含名为';方法';,java,spring,jsp,struts,tiles,Java,Spring,Jsp,Struts,Tiles,我找遍了,找不到我的问题的答案。根据我对DispatchAction的了解,这段代码应该可以正常工作。堆栈跟踪如下所示。我正在使用Struts1.3和带瓷砖的Spring进行布局 (请原谅我的代码块,我对使用stackoverflow非常陌生)如果您需要更多信息来帮助我,请告诉我。谢谢你抽出时间 javax.servlet.ServletException: Request[/authorizeShipment] does not contain handler parameter named

我找遍了,找不到我的问题的答案。根据我对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)
以下是我的代码片段:

调度行动:

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();

        }

    }
}
这是我的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>

在此处插入标题
授权装运ID
我的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

    <bean name="/authorizeShipment" class="com.multivision.mmt.action.AuthorizeShipmentAction"/>

引发异常是因为Struts在HTTP请求中找不到“method=xxxx”

我认为你应该从

<html:submit parameter="method" value="deny">

或其他一些用于隐藏的标记。
我的意思是,“method=deny”应该被视为

<input type="hidden" name="method" value="deny"/>

在JSP生成的HTML页面中。请检查一下

PS:您可以使用浏览器开发工具来检查HTTP请求。所有最近的浏览器都能做到这一点

<input type="hidden" name="method" value="deny"/>