微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

“构建成功”但“你好世界!”不显示 - NetBeans

如何解决“构建成功”但“你好世界!”不显示 - NetBeans

我使用的是 Apache NetBeans IDE 12.1 和 JDK 8。我使用 Maven > Web 应用程序项目创建了一个 Java,其中包含两个包,ejb 和 web。 ejb 包有一个 AccountManager 和一个 AccountManagerLocal。

客户经理:

@Stateless
public class AccountManager implements AccountManagerLocal {

    @Override
    public String ping() {
        return "ping";
    }

}

AccountManagerLocal:

@Local
public interface AccountManagerLocal {

    String ping();
    
}

我在web包中创建了一个Servlet:

@WebServlet(name = "AccountManagerServlet",urlPatterns = {"/AccountManagerServlet"})
public class AccountManagerServlet extends HttpServlet {

    @EJB
    private AccountManagerLocal accountManager;

    protected void processRequest(HttpServletRequest request,HttpServletResponse response)
            throws servletexception,IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* Todo output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet AccountManagerServlet</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet AccountManagerServlet at " + request.getcontextpath() + "</h1>");
            out.println("<h3>Result of ping()</h3>");
            out.println("<p>"+accountManager.ping()+"</p>");
            out.println("</body>");
            out.println("</html>");
        }
    }

    @Override
    protected void doGet(HttpServletRequest request,IOException {
        processRequest(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request,response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}

我只想运行整个项目 > 形象化“Hello World!”页面打开 > 然后运行文件 AccountManagerServlet > 可视化页面中的变化。

但由于某种原因,什么也没有发生。

Scanning for projects...

--------------------< com.mycompany:AccountManager >--------------------
Building AccountManager-1.0-SNAPSHOT 1.0-SNAPSHOT
--------------------------------[ war ]---------------------------------

--- maven-dependency-plugin:2.6:copy (default) @ AccountManager ---

--- maven-resources-plugin:2.6:resources (default-resources) @ AccountManager ---
Using 'UTF-8' encoding to copy filtered resources.
copying 1 resource

--- maven-compiler-plugin:3.1:compile (default-compile) @ AccountManager ---
Changes detected - recompiling the module!
Compiling 5 source files to C:\Users\UserA\Documents\NetBeansprojects\AccountManager\target\classes

--- maven-resources-plugin:2.6:testResources (default-testResources) @ AccountManager ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory C:\Users\UserA\Documents\NetBeansprojects\AccountManager\src\test\resources

--- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ AccountManager ---
nothing to compile - all classes are up to date

--- maven-surefire-plugin:2.12.4:test (default-test) @ AccountManager ---
No tests to run.

--- maven-war-plugin:2.3:war (default-war) @ AccountManager ---
Packaging webapp
Assembling webapp [AccountManager] in [C:\Users\UserA\Documents\NetBeansprojects\AccountManager\target\AccountManager-1.0-SNAPSHOT]
Processing war project
copying webapp resources [C:\Users\UserA\Documents\NetBeansprojects\AccountManager\src\main\webapp]
Webapp assembled in [78 msecs]
Building war: C:\Users\UserA\Documents\NetBeansprojects\AccountManager\target\AccountManager-1.0-SNAPSHOT.war
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time:  5.881 s
Finished at: 2021-02-22T14:02:17Z
------------------------------------------------------------------------
deploying on GlassFish Server
    profile mode: false
    debug mode: false
    force redeploy: true
In-place deployment at C:\Users\UserA\Documents\NetBeansprojects\AccountManager\target\AccountManager-1.0-SNAPSHOT
GlassFish Server,deploy,null,false

我认为问题出在 GlassFish 上,但我不确定。我已经再次安装了 NetBeans,但问题仍然存在。有人可以帮我打开页面吗?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?