Servlet,GET和POST形成问题

时间:2017-07-27 20:00:57

标签: forms jsp servlets

我只有一个servlet的问题,所有其他的(以相同的方式声明)工作得很好

有问题的Servlet:

package com.myproject.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class Connexion extends HttpServlet {

public static final String VUE = "/WEB-INF/connexion.jsp";

public void doGet( HttpServletRequest request, HttpServletResponse response ) 
        throws ServletException, IOException{
            this.getServletContext().getRequestDispatcher( VUE ).forward( request, response ); 
}

public void doPost( HttpServletRequest request, HttpServletResponse response ) 
        throws ServletException, IOException{
}
}

另一位工作的Servlet:

package com.myproject.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class Authentification extends HttpServlet {

public static final String VUE = "/WEB-INF/authentification.jsp";

public void doGet( HttpServletRequest request, HttpServletResponse response ) 
        throws ServletException, IOException{
            this.getServletContext().getRequestDispatcher( VUE ).forward( request, response ); 
}

public void doPost( HttpServletRequest request, HttpServletResponse response ) 
        throws ServletException, IOException{
}
}

调用servlet" Connexion" :

<form id="form_authentification" class="formulaire" method="post" action="connexion">
<input type="text"   class="input_text" title="<fmt:message key="mail_ou_nom" />" placeholder="<fmt:message key="mail_ou_nom" />" required />
<input type="submit" class="btn"        value="<fmt:message key="suivant" /> "/>

和web.xml:

<!-- Authentification -->

<servlet>
    <servlet-name>Authentification</servlet-name>
    <servlet-class>com.myproject.servlets.Authentification</servlet-class>
    <init-param>
        <param-name>auteur</param-name>
        <param-value>Atyss</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>Authentification</servlet-name>
    <url-pattern>/authentification</url-pattern>
</servlet-mapping>

<!-- Connexion -->

<servlet>
    <servlet-name>Connexion</servlet-name>
    <servlet-class>com.myproject.servlets.Connexion</servlet-class>
    <init-param>
        <param-name>auteur</param-name>
        <param-value>Atyss</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>Connexion</servlet-name>
    <url-pattern>/connexion</url-pattern>
</servlet-mapping>

所以如果我把方法&#34;得到&#34;形式为:&#34; form_authentification&#34; JSP authentification.jsp它的工作原理,但我在浏览器中排队:

http://localhost:8080/myproject/connexion?

来自&#34;?&#34;是在线浏览器吗?

如果我把方法&#34; post&#34;形式为:&#34; form_authentification&#34; JSP authentification.jsp我有一个connexion.jsp的白页和apache服务器的浏览器标记图标。

感谢您的回答

0 个答案:

没有答案