logaction.java
来自「用struts+hibernate+spring做的登录」· Java 代码 · 共 56 行
JAVA
56 行
package struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import form.UserForm;
import java.util.List;
public class LogAction extends BaseAction
{
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
{
UserForm userForm = (UserForm) form;
String username = userForm.getUsername();
String password = userForm.getPsw();
if(!this.getUserinfoService().exist(username, password))//判断该用户是否存在
{
// request.setAttribute("pswerror", "用户名不存在或密码错误!");
return mapping.findForward("fail");
}
else
{
List list=this.getUserinfoService().getInfo();
request.setAttribute("fa",list);
return mapping.findForward("suc");
}
}
}
//Query Q = session.createQuery("from customer as c where c.name = :customerName" + "and c.age = :customerAge");
//
//query.setString ("customerName" , "tom");
//
//query.setInteger("customerAge" , "21");
//
//list result = query.list();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?