写清你的类名。最好把整个类贴出来。再把你的struts-config.xml文件贴出来

解决方案 »

  1.   

    action类:
    package com.write.struts.action;import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.DataSource;import java.sql.*;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.write.struts.form.WriteForm;public class WriteAction extends Action { public ActionForward execute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws Exception {

    WriteForm writeForm = (WriteForm) form;

    Connection conn = null;
    DataSource dataSource=null;
    Statement stmt=null;

           try
      {
            dataSource = getDataSource(request);
            conn = dataSource.getConnection();
                 stmt = conn.createStatement();

    String g_title=writeForm.getTitle();
    String g_sort=writeForm.getSort();
    String g_author=writeForm.getAuthor();
    String g_describe=writeForm.getDescribe();
    String g_content=writeForm.getContent();

    stmt.executeUpdate("insert into sanjia values('"
                       +g_title+"','"+g_sort+"', '"+g_author+"', '"+g_describe+"', '"+g_content+"')");

    stmt.close();
    conn.close();
     }catch(SQLException e){
    writeForm.setContent(e.toString()+e.getMessage());
     }
     
     return (mapping.findForward("success"));
       }}struts-config.xml文件:
     <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
        
        <!-- ========== Data Source Configuration =============================== -->
        <data-sources>
            <data-source>
                <set-property property="url" value="jdbc:oracle:thin:@localhost:1521:oradb" />
                <set-property property="maxCount" value="10" />
                <set-property property="autoCommit" value="true" />
                <set-property property="user" value="system" />
                <set-property property="minCount" value="1" />
                <set-property property="driverClass" value="oracle.jdbc.driver.OracleDriver" />
                <set-property property="readOnly" value="false" />
                <set-property property="description" value="link to oracle" />
                <set-property property="password" value="manager" />
                <set-property property="loginTimeout" value="" />
            </data-source>
            
        </data-sources>
        
        <!-- ========== Form Bean Definitions ================================== -->
        <form-beans>
            <form-bean name="writeForm" type="com.write.struts.form.WriteForm">
                <form-property name="sort" type="java.lang.String" />
                <form-property name="author" type="java.lang.String" />
                <form-property name="content" type="java.lang.String" />
                <form-property name="describe" type="java.lang.String" />
                <form-property name="title" type="java.lang.String" />
            </form-bean>
            
        </form-beans>
        
             <action-mappings>
            <action
                attribute="writeForm"
                input="/write.jsp"
                name="writeForm"
                path="/write"
                type="com.write.struts.action.WriteAction">
                <forward name="failure" path="/failure.jsp" />
                <forward name="success" path="/success.jsp" />
            </action>
            
        </action-mappings>
        
            <message-resources parameter="com.write.struts.ApplicationResources" />
        
        
    </struts-config>谢谢大家