📄 expertaction.java
字号:
package struts.action;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
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 javabean.Expert;
import javabean.Sexpert;
import javabean.dbconnect;
public class ExpertAction extends Action {
Sexpert sexpert=new Sexpert();
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
dbconnect db=new dbconnect();
int maxid = 0;
String sql1="select max(id) as counter from EXPERT";
ResultSet rs1= db.executeQuery(sql1);
while(rs1.next())
{
maxid = rs1.getInt("counter");
}
Vector vec=new Vector();
String id1=request.getParameter("id");
int id=Integer.valueOf(id1).intValue();
int nextid=id+1;
int upid=id-1;
String sql="select * from EXPERT where ID='"+id+"'";
ResultSet rs=null;
try
{
rs=db.executeQuery(sql);
while(rs.next())
{
Expert show=new Expert();
show.setId(rs.getInt("ID"));
show.setRname(rs.getString("RNAME"));
show.setSex(rs.getString("SEX"));
show.setZhiwu(rs.getString("ZHIWU"));
show.setZhiche(rs.getString("ZHICHE"));
show.setMemo(rs.getString("MEMO"));
show.setPhoto(rs.getString("PHOTO"));
vec.add(show);
}
rs.close();
}
catch (SQLException e) { return null;}
request.setAttribute("vec",vec);
request.setAttribute("maxid",String.valueOf(maxid));
request.setAttribute("nextid",String.valueOf(nextid));
request.setAttribute("upid",String.valueOf(upid));
return mapping.findForward("success");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -