上午簡單地用JSP試驗,並希望在表格中顯示的所有條目,的Servlet不可用HTTP 404
我的servlet是這
package UserPass;
import data.UserPassDb;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author One
*/
public class UserPassController extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setAttribute("users", UserPassDb.selectAllUser());
String forward = "/me/testpage.jsp";
RequestDispatcher view = request.getRequestDispatcher(forward);
view.forward(request, response);
}
}
和我的測試頁
<a href="<c:url value='/test/TestServlet'/>">
refresh
</a><br><br>
<c:forEach var="user" items="${users}">
<c:out value="${user.user_name}"/>
</c:forEach>
謝謝你們..我正在做的教程,並試圖解決我自己的初學者問題,但一再失敗:(
等什麼我試圖在這裏做的,裝載的servlet以獲取會話對象其中包含用戶數據 – TrackmeifYouCan
「/ test/TestServlet」是applet的絕對路徑還是它的意思是相對路徑?如果是這樣刪除主導斜線。 – Lipongo
你可以在這裏發佈你的web.xml配置文件嗎 –