doaction.java
来自「本人尽量将很多暂时用不到的一些配置和初学者看不懂的东东去掉」· Java 代码 · 共 37 行
JAVA
37 行
package com.ligx;
import java.sql.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DoAction extends Action{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,
HttpServletResponse response){
ActionForward forward = new ActionForward();
DoForm tForm = (DoForm)form;
Integer id = tForm.getId();
String name = tForm.getName();
Integer sex = tForm.getSex();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:LogonData","sa","");
Statement stmt = conn.createStatement();
stmt.executeUpdate("insert into t_user values('"+id+"','"+name+"','"+sex+"')");
forward = mapping.findForward("success");
}
catch(Exception e)
{
System.out.println(e.toString());
forward = mapping.findForward("failed");
}
return forward;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?