public class textaction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String ward = null;
textform tf = (textform) form;
String mess = "";
Jdbc jdbc = new Jdbc();
Connection cot = (Connection) jdbc.getcon();
Statement st = null;
ResultSet rs = null;
List list = new ArrayList();
try {
st = cot.createStatement();
String sql = "select * from user";
// String sql = "select * from user where uname="+tf.getName();
rs = st.executeQuery(sql);
while (rs.next()) {
String aa = rs.getString(1);
list.add(aa);
}
if (tf.getName() != null && !"".equals(tf.getName())) {
for (int i = 0; i < list.size(); i++) {
if (!tf.getName().equals(list.get(i))
&& tf.getName() != list.get(i)) {
mess = "用户名错误";
request.setAttribute("mess", mess);
ward = "err";
System.out.println(ward + "111111111111111");
} else {
mess = "登入 ok.你登入的用户名";
request.setAttribute("mess", mess);
request.setAttribute("tf", tf);
request.setAttribute("list", list);
ward = "succ";
return mapping.findForward(ward);
}
}
}
else {
mess = "用户名为空";
request.setAttribute("mess", mess);
return mapping.findForward("err");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
cot.close();
rs.close();
st.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
System.out.println(ward);
return mapping.findForward(ward);
}
}
------解决方案--------------------
LZ想问啥?!
------解决方案--------------------
study
------解决方案--------------------
好像不是问问题的……
------解决方案--------------------
受教。。。
------解决方案--------------------
是晒代码,不看
------解决方案--------------------
路过。。。
------解决方案--------------------
学艺 ~~~~