提交表单时,它会将我重定向到所需的链接,但页面空白。
这是JSP中表单的代码:
<form class="inscription-form" method="post" action="apropos">
<hr style="color: blue">
<div class="form-group">
<input type="text" name="nom" id="nom" class="form-control"
placeholder="pseudo">
</div>
<button type="submit" class="btn btn-primary" >inscriprion</button>
</form>
当链接位于同一页面时,会显示404错误!
这是Java代码:
public class inscription extends HttpServlet {
private static final long serialVersionUID = 1L;
public inscription() {
super();
// TODO Auto-generated constructor stub
}
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
request.setAttribute("utilisateur",utilisateur);
this.getServletContext().getRequestDispatcher("/WEB-
INF/inscription.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
utilisateur = new Utilisateur();
utilisateur.setNom(request.getParameter("nom"));
request.setAttribute("utilisateur",utilisateur);
this.getServletContext().getRequestDispatcher("/WEB-INF/inscription.jsp")
.forward(request, response);
}
}
感谢您的帮助