1

Below Code is working fine in Mozila Firefox, Internet Explorer but giving above error 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);
}
}

Error Log

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.
2
  • Can you please specify what error are you getting exactly in Google Chrome? Jun 26, 2013 at 11:52
  • 2
    I don't understand the point of the JavaScript. What happens if you take out the question mark? It's not necessary and it all seems rather redundant. Jun 26, 2013 at 13:35

3 Answers 3

2

I think as you have not mentioned the parameter 'method' in the URL, you are getting the error. I am not sure how IE and FF is working, but if you construct the URL something like UsrAction.do?method=lodable I believe, it should work in chrome as well.

1
  • if we have multiple submit button then how we can handle Apr 15, 2017 at 11:05
2

The reason of the exception is that you have added a param parameter="method" in your Struts config file and system is now looking for method name in that variable which is not supplied by you in the code.

You should use hidden from property to provide the method name to avoid the exception.

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

Hope this will help someone,

0

I have faced the same issue because of a Javascript error, in my FormBean coming from action class, I put a new variable and have not put that to from, and then I was trying to get it from the form like

document.forms[0].VARIABLE_NAME.value

as this variable was not present in the Form but it was there in the FormBean so JS was unable to find it and was not submitting the form properly.

So, to fix the issue I used hidden form fields and put the new variable in the form and then used it from there. fixed my issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.