【发布时间】:2017-05-11 03:37:52
【问题描述】:
我有一个简单的 hello world webapp,当我在 tomcat 中使用 url http://localhost:8080/na/environment 运行它时工作正常; Wildfly 9 中的相同战争不起作用,我收到 404 错误。
谷歌搜索我发现一个 WildFly 项目需要 2 个文件(beans.xml 和 jboss-web.xml),我刚刚添加到项目中但仍然无法正常工作。
我的 wildldFly 管理控制台显示战争已部署并启用
这是我项目的结构:
而我的文件jboss-web.xml的内容是:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>/</context-root>
</jboss-web>
beans.xml 是空的(仍然不知道它的海豚是什么)。
最后,我的 servlet(也是唯一的类)的代码是:
@WebServlet(urlPatterns="/environment")
public class Environment extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.getWriter().append("Hello");
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
}
我尝试使用:
http://localhost:9990/na/environment/
http://localhost:9990/na.war/environment/
http://localhost:9990/environment/
【问题讨论】:
标签: web-applications wildfly-9