Ich mache eine einfache Web-App mit Java und Servlet, aber ich kann nicht scheinen, auf die Adresse zugreifen: http://localhost:8080/Financeiro/oi-mundo, die verfügbar sein sollte.
Hier ist meine Servlets:
Fehler 404 beim Versuch, auf mein Servlet zuzugreifen
import java.io.IOException;
import java.io.PrintWriter;
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 OiMundoServlet
*/
@WebServlet("/oi-mundo")
public class OiMundoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out = response.getWriter();
System.out.println("Ola mamae");
out.print("<html>");
out.print("<body><h1>Oi Mundo</h1></body>");
out.print("</html>");
out.flush();
}
}
Und hier ist pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.algaworks</groupId>
<artifactId>Financeiro</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Es gibt keine Fehler in dem Projekt noch in der Konsole nur eine Warnung:
[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Financeiro' did not find a matching property
.
Auch keine Nachricht erscheint in der Konsole beim Versuch, auf die Adresse zuzugreifen, aber ich bin mir nicht sicher, ob es sollte.
Ich hörte web.xml wie von Servlets 3.0 ist nicht erforderlich. –