java - Setting up simple struts 1.3 project, cannot find bean in ant scope -
i starting out struts maintain struts 1.3 application , after setting , deploying hello world application following error:
javax.servlet.servletexception: javax.servlet.jsp.jspexception: cannot find bean: "helloworldform" in scope org.apache.jasper.runtime.pagecontextimpl.dohandlepageexception(pagecontextimpl.java:865) org.apache.jasper.runtime.pagecontextimpl.handlepageexception(pagecontextimpl.java:794) org.apache.jsp.helloworld_jsp._jspservice(helloworld_jsp.java:75) org.apache.jasper.runtime.httpjspbase.service(httpjspbase.java:70) javax.servlet.http.httpservlet.service(httpservlet.java:723) org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:388) org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:313) org.apache.jasper.servlet.jspservlet.service(jspservlet.java:260) javax.servlet.http.httpservlet.service(httpservlet.java:723) my action class looks this:
package com.mkyong.common.action; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import org.apache.struts.action.action; import org.apache.struts.action.actionform; import org.apache.struts.action.actionforward; import org.apache.struts.action.actionmapping; import com.mkyong.common.form.helloworldform; public class helloworldaction extends action { public actionforward execute(actionmapping mapping,actionform form, httpservletrequest request,httpservletresponse response) throws exception { helloworldform helloworldform = (helloworldform) form; helloworldform.setmessage("hello world! struts"); return mapping.findforward("success"); } } my form class this:
package com.mkyong.common.form; import org.apache.struts.action.actionform; public class helloworldform extends actionform{ string message; public string getmessage() { return message; } public void setmessage(string message) { this.message = message; } } struts-config.xml this:
<form-beans> <form-bean name="helloworldform" type="com.mkyong.common.form.helloworldform"/> </form-beans> <action-mappings> <action path="/helloworld" type="com.mkyong.common.action.helloworldaction" name="helloworldform"> <forward name="success" path="/helloworld.jsp"/> </action> </action-mappings> helloworld.jsp this:
<html> <head> </head> <body> <h1><bean:write name="helloworldform" property="message" /> </h1> </body> </html> i wanted build upon not quite work , wondered if might point me in right direction.
any , advice appreciated.
yes reason not call directly page of jsp try access action class using action.
for example try access using action of "/helloworld.do"
and ya can access , print variable on jsp page using bean name have define
that way problem resolved.
Comments
Post a Comment