⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enrolinsertaction.java

📁 JAVA注册表 详细列表 系统设计 源码
💻 JAVA
字号:
/*
 * 创建日期 2002-1-1
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package action;

import java.sql.Connection;
import java.sql.Statement;

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 db.DbUtil;

public class enrolInsertAction extends Action {

    
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
         String name;
         String password;
         String email;
         String card_number;
         String sex;
         String home_town;
         String home_town1;
         String home_town2;
         String gt="";
         String []good_at;
         String h_m_call="";
         String []h_m_calls;
         String h_m_name="";
         String []h_m_names;
         String h_m_phone="";
         String []h_m_phones;
         String jian_yi;
    	
       name=new String(request.getParameter("t1").getBytes("iso-8859-1"));
       password=request.getParameter("t2");
       email=new String(request.getParameter("t4").getBytes("iso-8859-1"));
       card_number=request.getParameter("t5");
       sex=new String(request.getParameter("r1").getBytes("iso-8859-1"));
       home_town1=new String(request.getParameter("f1").getBytes("iso-8859-1"));
       home_town2=new String(request.getParameter("f2").getBytes("iso-8859-1"));
       good_at=request.getParameterValues("c1");
       h_m_calls=request.getParameterValues("a1");
       h_m_names=request.getParameterValues("a2");
       h_m_phones=request.getParameterValues("a3");
       jian_yi=new String(request.getParameter("ta").getBytes("iso-8859-1"));
       
       home_town=home_town1+"-"+home_town2;    	   

       if(good_at==null){
    	   gt="-";
       }else{
        for(int i=0;i<good_at.length;i++){   
               gt=gt+new String(good_at[i].getBytes("iso-8859-1"))+"-"; 
           }
       }
       
       if(h_m_calls==null){
    	   h_m_call="-";
       }else{
    	   for(int i=0;i<h_m_calls.length;i++){
    		   if(h_m_calls[i]==null){
    			   h_m_calls[i]=" ";
    		   }
    		   h_m_call=h_m_call+new String(h_m_calls[i].getBytes("iso-8859-1"))+"-"; 
    	   }
       }
       
       if(h_m_names==null){
    	   h_m_name="-";
       }else{
    	   for(int i=0;i<h_m_names.length;i++){
    		   h_m_name=h_m_name+new String(h_m_names[i].getBytes("iso-8859-1"))+"-";
    	   } 
       }
       
       if(h_m_phones==null){
    	   h_m_phone="-";
       }else{
    	   for(int i=0;i<h_m_phones.length;i++){
    		   h_m_phone=h_m_phone+new String(h_m_phones[i].getBytes("iso-8859-1"))+"-"; 
    	   }
       }
       
       Connection conn=(Connection)DbUtil.getConn();
       String sql="insert into inf  (name,password,email,card_number,sex,home_town,good_at,h_m_call,h_m_name,h_m_phone,jian_yi) values('"+name+"','"+password+"','"+email+"','"+card_number+"','"+sex+"','"+home_town+"','"+gt+"','"+h_m_call+"','"+h_m_name+"','"+h_m_phone+"','"+jian_yi+"')";
       Statement ss=conn.createStatement();
       ss.executeUpdate(sql);
       
       return mapping.findForward("success");
    }
   

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -