Struts1.x NoSuchMethodException的一種可能
阿新 • • 發佈:2019-02-12
DispatchAction發生錯誤
環境:
strut-config.xml檔案
jsp頁面
Action
錯誤資訊:
NoSuchMethodException
javax.servlet.ServletException: Action[/MOD101Action] does not contain specified method (check logs)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
java.lang.NoSuchMethodException: Action[/MOD101Action] does not contain specified method (check logs)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:261)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
發生原因
解決方法:
將protected改為public
環境:
strut-config.xml檔案
jsp頁面
Action
錯誤資訊:
NoSuchMethodException
javax.servlet.ServletException: Action[/MOD101Action] does not contain specified method (check logs)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
java.lang.NoSuchMethodException: Action[/MOD101Action] does not contain specified method (check logs)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:261)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
發生原因
在使用dispatchaction的時候,分發的方法為protected私有,無法進行分發。(是程式拷貝帶來的問題)。
將protected改為public
重新啟動伺服器,執行正常。