RegAction.javajavax.servlet.ServletException:未找到指定的URL操作配置
private static final String FORWARD_succ = "succ";
Connection con=null;
public Connection getcon()
{
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","root");
}catch(SQLException e)
{}
catch(ClassNotFoundException c)
{
}
return con;
}
public void closeConnection()
{
try
{
con.close();
}catch(SQLException e)
{}
}
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException
{
RegForm1 r=(RegForm1)form;
Connection con=getcon();
String v1=r.getFname();
String v2=r.getLname();
String v3=r.getUid();
String v4=r.getDob();
String v5=r.getPwd();
String v6=r.getCpwd();
String v7=r.getCity();
String v8=r.getSt();
String v9=r.getZc();
System.out.println(v1);
System.out.println(v2);
System.out.println(v3);
System.out.println(v4);
System.out.println(v5);
System.out.println(v6);
System.out.println(v7);
System.out.println(v8);
System.out.println(v9);
try
{
PrintWriter pw=response.getWriter();
Statement ps=con.createStatement();
int k=ps.executeUpdate("insert into reg values(v1,v2,v3,v4,v5,v6,v7,v8,v9)");
if(k==1)
pw.println("susccessfully stored");
con.commit();
}catch(SQLException s)
{
}
catch(IOException s)
{
}
return mapping.findForward("succ");
config.xml中
<form-bean name="regform" type="RegForm1"/>
</form-beans>
<global-exceptions/>
<global-forwards/>
<action-mappings>
<action name="regform" path="/reg" type="RegAction" validate="true input="/Register.jsp">
<forward name="succ" path="/success.jsp"/>
Iwant存儲在MySQL數據庫以下字段值。但我得到以下例外,爲什麼?
新用戶的詳細信息 名*: 姓*:
用戶ID *:
杜伯*:
密碼*:
confirmpassword *
城市*:
狀態*:
郵編*:
按鈕
HTTP狀態500 -
type Exception report
message
description The server encountered an internal error() that prevented it from fulfilling this request.
exception
javax.servlet.ServletException
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
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:729)
root cause
java.lang.NullPointerException
RegAction.execute(RegAction.java:75)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
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:729)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.29 logs.
的Apache Tomcat/5.5.29
我g你是否使用Struts,而不是結構。你在struts-config.xml中檢查了URL映射嗎? – kosa 2012-07-19 17:33:08
我只使用struts1.x –
SIVA
2012-07-19 17:35:54
顯示RegAction類和struts-config.xml文件的代碼。 – 2012-07-19 17:37:16