eclipse - 我在这个 JBOSS/Wildfly servlet 中的 URL 是什么?
问题描述
我正在尝试学习 Wildfly 开发。我正在使用 Francesco Marchioni 的书“Java EE 7 Development with WildFly”。我只是想让 Hello World servlet 工作,但是当我转到“ http://localhost:8080/hello/test ”时出现 404 错误。根据这本书,@WebServlet("/test")放弃了使用 web.xml 文件的要求。有没有人有任何想法?
这是文件Webcontent/WEB_INF/jboss-web-xml
<jboss-web>
<context-root>/hello</context-root>
</jboss-web>
和TestServlet.java
package com.packtpub.wflydevelopement.chapter2;
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 TestServlet
*/
@WebServlet("/test")
public class TestServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html;charset=UTF-8";
private static final String MESSAGE = "<!DOCTYPE html><html>" + "<head><title>Hello!</title></head>"
+ "<body>Hello World WildFly</body>" + "</html>";
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
try (PrintWriter out = response.getWriter()) {
out.println(MESSAGE);
}
}
}
也是启动日志的一部分。
0:42:58,166 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Estrella Galicia' 9.3.1.Final
20:42:58,828 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 72) WFLYCLINF0002: Started client-mappings cache from ejb container
20:42:59,676 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 74) WFLYUT0021: Registered web context: '/hello' for server 'default-server'
20:42:59,693 INFO [org.jboss.as.server] (ServerService Thread Pool -- 42) WFLYSRV0010: Deployed "HelloWorld.war" (runtime-name : "HelloWorld.war")
20:42:59,904 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
20:42:59,913 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
20:42:59,914 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
20:42:59,914 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 14.0.1.Final (WildFly Core 6.0.2.Final) started in 27197ms - Started 405 of 590 services (326 services are lazy, passive or on-demand)
解决方案
推荐阅读
- c# - 网络服务客户端
- ssl - 错误 [Producer clientId=console-producer] 连接到节点 -1 (/myip-address:9096) 身份验证失败,原因是:SSL 握手失败
- c++ - Flex/Bison - 我如何解决“'symtab' 的多重定义”
- django - while connecting to MicrosoftSQL server using Django facing django.db.utils.OperationalError:
- reactjs - 如何在 goDaddy 上修复 reactJS 的白屏
- kubernetes - 用于多个部署的 PersistentVolume 和 PersistentVolumeClaim
- python - 如何从多个列表/字典创建多个数据框
- git - 放弃对 Gerrit 的提交
- jsp - Intellij CE 是否支持 .jsp?
- python - Django覆盖保存方法以一次保存多个对象