HTTP Status 500 - Action instance for path / adduser cannot be created in struts

I have a JSP page that has a hyperlink for adding a user.

<html:link action="openadduser.do"> Add New User < /html:link> 

My Struts settings file contains

 <action-mappings> <action path="/login" name="LoginForm" validate="true" input="/index.jsp" type="useraction.LoginAction"> <forward name="successadmin" path="/home.jsp" /> <forward name="failure" path="/index.jsp" /> <forward name="successuser" path="/welcome.jsp" /> </action> <action path="/adduser" name="AdduserForm" validate="true" input="/adduser.jsp" type="useraction.AdduserActions"> <forward name="success" path="/userconfirm.jsp" /> </action> <action path="/openadduser" name="AdduserForm" validate="true" type="useraction.AdduserAction" input="/adduser.jsp"> <forward name="success" path="/userconfirm.jsp" /> </action> </action-mappings> 

And my adduser.jsp contains the code

 <html:form action="/adduser"> < h1 align="center"> ADD NEW USER < /h1> < bean:message key="label.fname"/> <br/> <html:text property="fname"></html:text><br/> <html:errors property="fname" /><br/> </html:select> <html:submit/> </html:form></body></html> 

AdduserAction.java contains

 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { AdduserForm adduserForm = (AdduserForm) form; fname = adduserForm.getFname().toString(); System.out.println(fname); return mapping.findForward("success"); } 

I am using a Tomcat server. After I click the "Submit" button to add a user, the following error appears. HTTP Status 500 - You cannot create an action instance for the / adduser path in struts.

I think there is a problem in the Struts-config file. What can I do to remove this error? Thank you for your help.

+4
source share
3 answers

I think adding .do to your jsp should solve the problem

 <html:form action="adduser.do"> 
+2
source

You cannot extend the Action class in your LoginAction . This is the only reason for no action instance for path . You must extend the Action class, do not forget ...

+2
source

@vicky: change action tag validate="true" to validate="false"

It worked for me ...

0
source

Source: https://habr.com/ru/post/1387139/


All Articles