Web应用程序:Maven清理后,请求的资源不可用

时间:2017-01-10 21:21:05

标签: eclipse maven servlets

我有一个动态的网络项目,已经多次完美地工作了,但是在进入Run As>之后Maven干净,我尝试再次运行我的应用程序,当我尝试转到网址http://localhost:8080/Servlet_Project/AccountServlet时,我收到一条错误消息,说明请求的资源不可用。没有抛出异常 - 我似乎无法访问servlet。这是我的AccountServlet.java。我还在web.xml中映射了servlet,但认为由于注释而没有必要。

@WebServlet("/AccountServlet")
public class AccountServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public AccountServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/account.jsp").forward(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PrintWriter out = response.getWriter();
        String username = request.getParameter("username");
        String password = request.getParameter("password");

    HibernateClient hc = HibernateClient.getInstance();
    Accounts a = hc.getAccount(username, password);
            if(a==null){request.getRequestDispatcher("/login.jsp").forward(request, response);

            }
            else{
            HttpSession sess = request.getSession(); 
            sess.setMaxInactiveInterval(600);
            sess.setAttribute("username", username);
            sess.setAttribute("firstName", a.getFirstname());
            sess.setAttribute("lastName", a.getLastname());
            sess.setAttribute("address", a.getAddress());
            sess.setAttribute("state", a.getState());
            sess.setAttribute("country", a.getCountry());
            sess.setAttribute("phone", a.getPhone());
            sess.setAttribute("SSN", a.getSsn());
            sess.setAttribute("email", a.getEmail());
            sess.setAttribute("city", a.getCity());
            String balances = (a.getBalance()).toString();
            double balance = Math.round(Double.parseDouble(balances)* 100d) 
            sess.setAttribute("balance", balance);
            request.getRequestDispatcher("/account.jsp").forward(request, response);}}
}

0 个答案:

没有答案