DispatchAction ServletException:Request不包含名为'method'的处理程序参数

时间:2014-06-04 02:46:06

标签: java spring jsp struts tiles

我到处搜索过,无法找到问题的答案。根据我对DispatchAction的了解,这段代码应该可以正常工作。堆栈跟踪如下。我正在使用Struts1.3和Spring与tile进行布局 (请原谅我的代码块我是使用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)

以下是我的代码段:

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

        }

    }
}

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

我的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>

我的action-servlet.xml

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

1 个答案:

答案 0 :(得分:3)

引发异常是因为Struts找不到&#34; method = xxxx&#34;在HTTP请求中。

我认为你应该改变

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

<html:hidden parameter="method" value="deny"> or some other tags for hidden.

我的意思是,&#34;方法=拒绝&#34;应该看作是

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

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

PS:您可以使用Browser Developer工具检查HTTP请求。所有最近的浏览器都可以做到。