简体   繁体   English

Servlet doGet()未更新

[英]Servlet doGet() is not updating

I have simple Srvlet class with following Get method: 我有简单的Srvlet类,具有以下Get方法:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    System.out.println("Hello from Get method");
}

When I try to run this on Tomcat server , 8.5, I get the following message on browser : "Served at: /SimpleServletProject". 当我尝试在Tomcat服务器8.5上运行此程序时,在浏览器上收到以下消息:“服务于:/ SimpleServletProject”。 This was the message which i removed from the default implementation of the Servlet. 这是我从Servlet的默认实现中删除的消息。 And nothing is getting printed on Console. 控制台上没有任何内容。 Somehow my changes are not reflecting. 不知何故,我的更改没有反映出来。

Try this one 试试这个

protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        System.out.println("Hello from Get method");

}

In your web.xml you should map your servlet like 在web.xml中,您应该像

<servlet>
<servlet-name>ServletName</servlet-name>
<servlet-class>full path of class</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletName</servlet-name>
<url-pattern>/url</url-pattern>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM