首页上一页 1 下一页尾页 1 条记录 1/1页
再开一贴,虚心请教
发表在JavaWeb图书答疑
2007-12-28
是否精华
是
否
版块置顶:
是
否
我是将光盘里的代码COPY进MYECLIPSE的,可是还是login界面无论密码用户名是否正确输入都智能跳转到http://127.0.0.1/equipment/manager.do?action=login界面,此界面无任何内容,为空白。而不能跳转到所指的main.jsp或者error.jsp界面,在struts-config里已经设置了<action-mappings >
<action
attribute="managerForm"
name="managerForm"
path="/manager"
scope="request"
type="com.action.ManagerAction">
<forward name="managerLoginok" path="/main.jsp" />
<forward name="error" path="/error.jsp" />
</action>
</action-mappings>
在manageraction里也设置了public class ManagerAction extends Action {
/*
* Generated Methods
*/
private ManagerDAO managerDAO=null;
public ManagerAction(){
this.managerDAO=new ManagerDAO();
}
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
String action=request.getParameter("action");
if(action==null||"".equals(action)){
return mapping.findForward("error");
}else if("login".equals("action")){
return managerLogin(mapping,form,request,response);
}
request.setAttribute("error","操作失败!");
return mapping.findForward("error");
}
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward managerLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
ManagerForm managerForm = (ManagerForm) form;
managerForm.setName(managerForm.getName());
managerForm.setPwd(managerForm.getPwd());
int ret = managerDAO.checkManager(managerForm);
if(ret==1){
HttpSession session=request.getSession();
session.setAttribute("manager",managerForm.getName());
return mapping.findForward("managerLoginok");
}
else{
request.setAttribute("error","您输入的管理员名称或密码错误!");
return mapping.findForward("error");
}
}
}
请教!!
<action
attribute="managerForm"
name="managerForm"
path="/manager"
scope="request"
type="com.action.ManagerAction">
<forward name="managerLoginok" path="/main.jsp" />
<forward name="error" path="/error.jsp" />
</action>
</action-mappings>
在manageraction里也设置了public class ManagerAction extends Action {
/*
* Generated Methods
*/
private ManagerDAO managerDAO=null;
public ManagerAction(){
this.managerDAO=new ManagerDAO();
}
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
String action=request.getParameter("action");
if(action==null||"".equals(action)){
return mapping.findForward("error");
}else if("login".equals("action")){
return managerLogin(mapping,form,request,response);
}
request.setAttribute("error","操作失败!");
return mapping.findForward("error");
}
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward managerLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
ManagerForm managerForm = (ManagerForm) form;
managerForm.setName(managerForm.getName());
managerForm.setPwd(managerForm.getPwd());
int ret = managerDAO.checkManager(managerForm);
if(ret==1){
HttpSession session=request.getSession();
session.setAttribute("manager",managerForm.getName());
return mapping.findForward("managerLoginok");
}
else{
request.setAttribute("error","您输入的管理员名称或密码错误!");
return mapping.findForward("error");
}
}
}
请教!!