1

我为我的应用程序创建了一个 servlet.java 文件并将其添加到 web.xml 中,如下所示:

小服务程序:

public class CheckServlet extends HttpServlet implements Servlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try (PrintWriter out = response.getWriter()) {
            response.setContentType("text/html");
            out.print("<html><body>");
            out.printf("Application '%s' is active", getServletContext().getServletContextName());
            out.print("</body></html>");
            out.flush();
        }catch(IOException e) {
            logger.error("IO Exception");
        }
    }
}

web.xml

<servlet>
    <servlet-name>CheckServlet</servlet-name>
    <servlet-class>com.adapter.CheckServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>CheckServlet</servlet-name>
    <url-pattern>/check.html</url-pattern>
</servlet-mapping>

我在我的本地(UT 环境,本地主机)中有自由服务器,并且我得到了成功的响应。

在此之后,我使用 udeploy 将应用程序部署到更高环境的另一个 WAS 服务器(WebSphere 应用程序服务器)。但是当我点击那里的 URL 时,它会抛出错误

错误 404:

com.ibm.ws.webcontainer.servlet.exception.NoTargetForURIException:没有为 uri 配置目标 servlet:/check.html

上下文根和 URL 是正确的。
我该如何解决这个问题?

4

2 回答 2

0

如果您尝试使用 http 访问,请尝试将 URL 更改为 https,并使用服务器中配置的正确 https 端口。

仅当您 100% 确定上下文根在正确的情况下是正确的。

于 2018-05-06T04:16:17.643 回答
0

我发现http服务器没有正确配置,所以它显示错误

于 2018-05-07T06:13:44.310 回答