Results 1 to 3 of 3
  1. #1
    kondiweyane's Avatar
    kondiweyane is offline Member
    Join Date
    Jan 2010
    Location
    Mountain Hua,Xi'AN,China
    Posts
    17
    Rep Power
    0

    Red face spring2.0struts1.2hibernate3.0Demo_bookStore

    my admin user can't in next jsp, doesn't work.don't come "else {...}" in code.

    thanks in advanced.

    part code

    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    String loginname=request.getParameter("loginname");
    String password=request.getParameter("password");
    System.err.print("admin-name===="+loginname+"$##$pass====44=="+password);
    if(request.getSession().getAttribute("admin")==nul l){
    request.setAttribute("msg", "plz admin info is Okay");
    return mapping.findForward("err");
    }else {
    ....}
    ................

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    It should not go into else if request.getSession().getAttribute("admin") is not null because that is what you coded as your rules.

  3. #3
    kondiweyane's Avatar
    kondiweyane is offline Member
    Join Date
    Jan 2010
    Location
    Mountain Hua,Xi'AN,China
    Posts
    17
    Rep Power
    0

    Default

    it's all code in this class。

    "loginname" and " password" both are received,my mind is poor?

    code:

    package com.kang.struts.action;

    import java.util.List;

    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 com.kang.bean.BookOrderBean;
    import com.kang.bean.PageBean;
    import com.kang.biz.BookBiz;


    public class OrderListAction extends Action {
    private BookBiz bookBiz;

    public void setBookBiz(BookBiz bookBiz) {
    this.bookBiz = bookBiz;
    }



    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception {
    String loginname=request.getParameter("loginname");
    String password=request.getParameter("password");
    System.err.print("admin-name===="+loginname+"$##$pass====44=="+password);
    if(request.getSession().getAttribute("admin")==nul l){
    request.setAttribute("msg", "请确保 管理员登陆信息正确");
    return mapping.findForward("err");
    }else {
    Object sessionPageBean=request.getSession().getAttribute( "adminPageBean");
    PageBean pageBean=new PageBean();
    int orderCount=bookBiz.findAllBooksCount();
    if(orderCount==0){
    request.setAttribute("orderList", null);
    return mapping.findForward("succ");
    }pageBean.setRsCount(orderCount);
    //System.err.print("orderCount=$$=="+orderCount);
    int pageCount=(orderCount+PageBean.ADMIN_PAGE_SIZE-1)/PageBean.ADMIN_PAGE_SIZE;
    pageBean.setPageCount(pageCount);
    int currentPage=1;
    if(sessionPageBean==null){
    pageBean.setCurrentPage(currentPage);
    pageBean.setBackwards(currentPage+1);
    pageBean.setFrontward(currentPage);
    request.getSession().setAttribute("adminPageBean", pageBean);
    }else{
    try{
    currentPage=Integer.parseInt(request.getParameter( "currentPage"));
    }catch(Exception e){
    currentPage=1;
    }pageBean.setCurrentPage(currentPage);
    pageBean.setBackwards((currentPage+1)>=pageCount?p ageCount:(currentPage+1));
    pageBean.setFrontward((currentPage-1)<=0?1:(currentPage-1));
    request.getSession().setAttribute("adminPageBean", pageBean);
    }List<BookOrderBean> orderList=bookBiz.findAllBookOrder(currentPage);
    if(orderList!=null&&orderList.size()>0){
    request.setAttribute("orderList", orderList);
    return mapping.findForward("succ");
    }else{
    request.setAttribute("msg", "管理员登陆信息有误");
    return mapping.findForward("err");
    }
    }
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •