📄 enrolupdateaction.java
字号:
package action;
import java.sql.Connection;
import java.sql.PreparedStatement;
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 enrolUpdateAction 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;
int im=Integer.parseInt(request.getParameter("id"));
System.out.println(im);
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();
PreparedStatement ps=conn.prepareStatement("update inf set name='"+name+"',password='"+password+"',email='"+email+"',card_number='"+card_number+"',sex='"+sex+"',home_town='"+home_town+"',good_at='"+gt+"',h_m_call='"+h_m_call+"',h_m_name='"+h_m_name+"',h_m_phone='"+h_m_phone+"',jian_yi='"+jian_yi+"' where id=?");
ps.setInt(1, im);
ps.executeUpdate();
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -