【发布时间】:2018-10-30 12:15:47
【问题描述】:
我正在尝试使用名称和密码创建一个简单的表单。但是,当我单击表单上名为“inscription”的验证按钮时,出现错误 404。我的错误是:ETAT 404 HTTP-/inscription 类型:Rapport d'état 消息:/题字 说明:资源不可用 这就是我的全部。
我应该得到一个空白页面,因为我的 post 方法中没有任何内容。
这是我的新 JSP 文件inscription.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!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=UTF-8">
<title>Inscription</title>
<link type="text/css" rel="stylesheet" href="<c:url value="/inc/style.css"/>" />
</head>
<body>
<form method="post" action="/inscription">
<fieldset>
<legend>Inscription</legend>
<p>Vous pouvez vous inscrire via ce formulaire.</p>
<label for="email">Adresse email <span class="requis">*</span></label>
<input type="text" id="email" name="email" value="" size="20" maxlength="60" />
<br />
<label for="motdepasse">Mot de passe <span class="requis">*</span></label>
<input type="password" id="motdepasse" name="motdepasse" value="" size="20" maxlength="20" />
<br />
<label for="confirmation">Confirmation du mot de passe <span class="requis">*</span></label>
<input type="password" id="confirmation" name="confirmation" value="" size="20" maxlength="20" />
<br />
<label for="nom">Nom d'utilisateur</label>
<input type="text" id="nom" name="nom" value="" size="20" maxlength="20" />
<br />
<input type="submit" value="Inscription" class="sansLabel" />
<br />
</fieldset>
</form>
</body>
</html>
这是我的新 servlet Inscription.java:
package com.sdzee.pro.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Inscription
*/
@WebServlet( "/inscription" )
public class Inscription extends HttpServlet {
private static final long serialVersionUID = 1L;
public static final String VUE = "/WEB-INF/inscription.jsp";
/**
* @see HttpServlet#HttpServlet()
*/
public Inscription() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append( "Served at: " ).append( request.getContextPath() );
this.getServletContext().getRequestDispatcher( VUE ).forward( request, response );
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
public void doPost( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
// TODO Auto-generated method stub
doGet( request, response );
}
}
这是我的 web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>Inscription</servlet-name>
<servlet-class>com.sdzee.pro.servlets.Inscription</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Inscription</servlet-name>
<url-pattern>/inscription</url-pattern>
</servlet-mapping>
</web-app>
【问题讨论】:
标签: jsp servlets jakarta-ee