WildFly 9部署简单的webapp但404

时间:2017-05-11 03:37:52

标签: web-applications wildfly-9

我有一个简单的hello world webapp,当我在tomcat中使用url http://localhost:8080/na/environment运行它时工作正常;在wildfly 9中的相同战争不起作用,我得到404错误。

谷歌搜索我发现一个WildFly项目需要2个文件(beans.xml和jboss-web.xml),我刚刚添加到项目中但仍然无法正常工作。

我的wildldFly管理控制台说战争已部署并启用

wildFly console

这是我项目的结构:

project structure

我的文件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/

0 个答案:

没有答案