hello guy's i am new in struts while running a program in struss i got an error like this....
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:531)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:901)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:830)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
org.apache.jsp.insert_jsp._jspx_meth_html_005fform_005f0(insert_jsp.java:136)
org.apache.jsp.insert_jsp._jspx_meth_html_005fhtml_005f0(insert_jsp.java:106)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
mycode are like this......
web.xml
<web-app>
<servlet>
<servlet-name>one</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>one</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
struts-config.xml
<struts-config>
<form-beans>
<form-bean name="insertForm" type="com.cac.struts.InsertForm">
</form-beans>
<action-mappings>
<action path="/insert" type="com.cac.struts.InsertAction" name="insertForm">
<forward name="success" path="/success.jsp">
<forward name="failure" path="/failure.jsp">
</action>
</action-mappings>
</struts-config>
hello guy's i am new in struts while running a program in struss i got an error like this....
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:531)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:901)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:830)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:798)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:506)
org.apache.jsp.insert_jsp._jspx_meth_html_005fform_005f0(insert_jsp.java:136)
org.apache.jsp.insert_jsp._jspx_meth_html_005fhtml_005f0(insert_jsp.java:106)
org.apache.jsp.insert_jsp._jspService(insert_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
mycode are like this......
InsertModel.java
package com.cac.struts;
import java.sql.*;
public class InsertModel
{
public boolean insert(String name,String branch,int regd)
{
boolean b=false;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:mohit","system","rock");
PreparedStatement ps=con.prepareStatement("insert into emp values(?,?,?)");
ps.setString(1,name);
ps.setString(2,branch);
ps.setInt(3,regd);
int k=ps.executeUpdate();
if(k>0)
b=true;
}
catch(Exception e)
{
e.printStackTrace();
}
return b;
}
}
InsertForm.java
package com.cac.struts;
import org.apache.struts.action.ActionForm;
public class InsertForm extends ActionForm
{
private int regd;
private String name;
开发者_JAVA技巧 private String branch;
public void setRegd(int r)
{
regd=r;
}
public int getRegd()
{
return regd;
}
public void setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
public void setBranch(String branch)
{
this.branch=branch;
}
public String getBranch()
{
return branch;
}
}
InsertAction.java
package com.cac.struts;
import org.apache.struts.action.*;
import javax.servlet.http.*;
public class InsertAction extends Action
{
public ActionForward execute(ActionMapping am,ActionForm af,HttpServletRequest hreq,HttpServletResponse hres) throws Exception
{
String key="failure";
InsertForm iif=(InsertForm)af;
int regd=iif.getRegd();
String name=iif.getName();
String branch=iif.getBranch();
InsertModel im=new InsertModel();
boolean b=im.insert(name,branch,regd);
if(b)
{
key="success";
}
ActionForward af1=am.findForward(key);
return af1;
}
}
web.xml
<web-app>
<servlet>
<servlet-name>one</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>one</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
struts-config.html
<struts-config>
<form-beans>
<form-bean name="insertForm" type="com.cac.struts.InsertForm">
</form-beans>
<action-mappings>
<action path="/insert" type="com.cac.struts.InsertAction" name="insertForm">
<forward name="success" path="/success.jsp">
<forward name="failure" path="/failure.jsp">
</action>
</action-mappings>
</struts-config>
insert.jsp
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:html>
<body bgcolor="yellow">
<center>
<h1>Student Application</h1>
<html:form action="insert" method="post">
regd<html:text property="regd"/><br><br>
name<html:text property="name"/><br><br>
branch<html:text property="branch"/><br><br>
<html:submit>insert</html:submit>
</html:form>
</center>
</body>
</html:html>
in addition i am also using all the jar files in lib and a struts-html.tld. Please...Please help me...!!
Adding commons-beanutils jar to your classpath may resolve the issue.
you did not add input in action mapping ..in struts-config.xml input="/insert.jsp"
try this
< action path="/insert" type="com.cac.struts.InsertAction"
name="insertForm" scope="request" validate="false" input="/insert.jsp">
ok
Probably you made entries in web.xml first and later you added the required jars especially commons-beanutils.jar. Simply delete the contents of web.xml and rewrite them.
Please make sure you have included following jars in your project
- antlr-2.7.6.jar
- commons-beanutils-1.7.0.jar
- commons-chain-1.2.jar
- commons-collections-3.1.jar
- commons-digester-2.0.jar
- commons-fileupload-1.2.2.jar
- commons-io-2.0.1.jar
- commons-lang-2.5.jar
- commons-logging-1.1.1.jar
- commons-logging-api-1.1.jar
- commons-validator-1.3.1.jar
- dom4j-1.6.1.jar
- hibernate-jpa-2.0-api-1.0.1.Final.jar
- hibernate3.jar
- javassist-3.12.0.GA.jar
- jstl-api-1.2.jar
- jstl-impl-1.2.jar
- jta-1.1.jar
- mysql-connector-java-5.1.17-bin.jar
- ognl-3.0.1.jar
- slf4j-api-1.6.1.jar
- slf4j-log4j12-1.6.2.jar
- spring-beans-2.5.6.jar
- spring-context-2.5.6.jar
- spring-core-2.5.6.jar
- spring-test-2.5.6.jar
- spring-web-2.5.6.jar
- struts2-core-2.2.3.1.jar
- xwork-core-2.2.3.1.jar
If still face problem please download following sample project from google code
http://struts-workspace-setup.googlecode.com/svn/trunk/
You missed mapping in web.xml
, it should be like this:
<web-app>
<servlet>
<servlet-name>one</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>one</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>
Also rename struts-config.html
to struts-config.xml
.
精彩评论