当我在登录后打开页面时总是找不到Home.jsp
,我不知道我的脚本有什么问题,这是我的代码,这是我的代码:
public class LoginController extends HttpServlet {
public LoginController()
{
sandiBank = "null";
session = null;
mUserDao = new MUserDao();
sandiBIDao = new SandiBIDao();
cabangDao = new CabangDao();
parameterDao = new ParameterDao();
mAccesDao = new MAccesDao();
}
@Override
protected void doGet(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
throws ServletException, IOException
{
httpservletrequest.getRequestDispatcher("WEB-INF/login.jsp").forward(httpservletrequest, httpservletresponse);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
String user = request.getParameter("user");
String pass = request.getParameter("pass");
MUser mUser = mUserDao.getMUser(user);
if(!mUser.isCheck())
{
RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/login.jsp");
dispatcher.forward(request, response);
} else
{
Cabang cabang = cabangDao.getSandiBank(mUser.getKdCab());
if(cabang.getSandiBank() != null)
sandiBank = cabang.getSandiBank();
RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/home.jsp");
dispatcher.include(request, response);
session = request.getSession(true);
session.setAttribute("userid", user);
session.setAttribute("passwd", pass);
String userid = (String)session.getAttribute("userid");
session.setAttribute("kdcaba", mUser.getKdCab());
session.setAttribute("sndbnk", sandiBank);
System.out.println(session.getAttribute("sndbnk"));
session.setAttribute("sandikd_bank", parameterDao.getSandiBank());
session.setMaxInactiveInterval(3600);
request.setAttribute("sandiBI", sandiBIDao.getSandiBI());
request.setAttribute("mAccesses", mAccesDao.getmAccesses(userid));
dispatcher.forward(request, response);
}
}
private static final long serialVersionUID = 1L;
private MUserDao mUserDao;
private SandiBIDao sandiBIDao;
private MAccesDao mAccesDao;
private CabangDao cabangDao;
private ParameterDao parameterDao;
private String sandiBank;
private HttpSession session;
}
答案 0 :(得分:0)
尝试替换
RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/home.jsp");
通过
RequestDispatcher dispatcher = request.getRequestDispatcher("home.jsp");
因为login.jsp和home.jsp在同一目录中
请改为<li><a href="LoginController" class="first">Home</a></li>
答案 1 :(得分:0)
尝试
RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/home.jsp");
“/”被解释为相对于当前上下文根。