Anfrage[/UsrAction] nicht enthalten hf-parameter mit der Bezeichnung 'Methode'. Dies kann verursacht werden durch ein Leerzeichen im label-text
Code unten ist in Ordnung, die in Mozila Firefox, Internet Explorer, sondern geben über Fehler in google chrome.
adminlogin.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Admin Role Page</title>
<script type="text/javascript">
function submitForm()
{
document.forms[0].action = "UsrAction.do?";
document.forms[0].submit();
}
</script>
</head>
<body>
<html:form action="/UsrAction" >
<html:submit property="method" value="lodable" onclick="submitForm() " />
<html:submit property="method" value="adduser" onclick="submitForm()" />
<html:submit property="method" value="addprogram" onclick="submitForm()"/>
</html:form>
</body>
</html>
struts-config.xml
<action input="/adminLogin.jsp" parameter="method" name="UsrForm" path="/UsrAction" scope="session" type="com.me.action.UsrAction">
<forward name="lodable" path="/pages/Lodable.jsp" />
<forward name="adduser" path="/pages/add.jsp" />
<forward name="addprog" path="/pages/program.jsp" />
</action>
UerAction.java
public class UsrAction extends DispatchAction {
private final static String lodable = "lodable";
private final static String adduser = "adduser";
private final static String addprog = "addprog";
public ActionForward lodable(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception {
UsrForm userForm = (UsrForm) form;
lgnDTO login = new lgnDTO();
request.setAttribute("login", login.getUsername());
return mapping.findForward(lodable);
}
public ActionForward adduser(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception {
UsrForm userForm = (UsrForm) form;
lgnDTO login = new lgnDTO();
return mapping.findForward(addprog);
}
public ActionForward addprogram(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception {
UsrForm userForm = (UsrForm) form;
lgnDTO login = new lgnDTO();
return mapping.findForward(adduser);
}
}
Fehlerprotokoll
type Exception report
message Request[/UsrAction] does not contain handler parameter named 'method'. This may be caused by whitespace in the label text.
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Request[/UsrAction] does not contain handler parameter named 'method'. This may be caused by whitespace in the label text.
org.apache.struts.actions.DispatchAction.unspecified(DispatchAction.java:197)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:245)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
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:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.39 logs.
- Können Sie bitte angeben, welche Fehler sind Sie immer genau das in Google Chrome?
- Ich verstehe nicht, den Punkt der JavaScript. Was passiert, wenn Sie das Fragezeichen? Es ist nicht notwendig, und es scheint alles ziemlich redundant.
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich denke, da Sie nicht erwähnt haben Sie den parameter 'method' in der URL, Sie sind der Fehler. Ich bin nicht sicher, wie Sie IE und FF funktioniert, aber wenn Sie den Aufbau der URL so etwas wie
UsrAction.do?method=lodable
Ich glaube, es sollte funktionieren, in chrome als auch.Der Grund für die Ausnahme ist, dass Sie Hinzugefügt haben, ein param
parameter="method"
in Ihrem Struts-config-Datei und das system ist nun auf der Suche für die Methoden-Namen in die variable, die nicht geliefert, indem Sie in den code.Sollten Sie verwenden, ausgeblendet-Eigenschaft zu bieten, den Namen der Methode zu vermeiden, die Ausnahme.
Hoffe, dies hilft jemand,