2012-08-10 10 views
0

的servlet我有JoinCustomerToAccountServlet的servlet下src/controller -不能調用從JSP頁面的表單

@WebServlet("/JoinCustomerToAccountServlet") 
public class JoinCustomerToAccountServlet extends HttpServlet { 
    private static final long serialVersionUID = 1L; 
    protected void doPost(HttpServletRequest request, 
      HttpServletResponse response) throws ServletException, IOException { 


    } 

} 

,並形成joinCustomerToAccount.jspWebContent/ActionsPages -

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title></title> 
</head> 
<body> 
     <form action="JoinCustomerToAccountServlet" method="POST"> 
      Account join to him : <input type="text" name="account" /> 
      <input type="submit" value="join" /> 

</body> 
</html> 

後,我填寫提交按鈕的形式,按我得到

type Status report 

message /MyBankProject/ActionsPages/JoinCustomerToAccountServlet 

description The requested resource (/MyBankProject/ActionsPages/JoinCustomerToAccountServlet) is not available. 

它看起來像在他的文件夾下搜索並不搜索servlet。

+0

@WebServlet(「/ JoinCustomerToAccountServlet」)我認爲這將從應用程序的根目錄映射servlet。 – 2012-08-10 10:35:16

回答

2

因爲你的URL映射爲/JoinCustomerToAccountServlet因爲你的JSP駐留內/MyBankProject/ActionsPages,你必須改變你的窗體的行動統一到這一點:

<form action="../JoinCustomerToAccountServlet",使其工作。