简体   繁体   English

运行Servlet时出错?

[英]Error while running Servlet?

I have the servlet name ExampleServlet.java which have only init method with HttpServletRequest and HttpServletResponse parameters. 我有Servlet名称ExampleServlet.java,它只有带有HttpServletRequest和HttpServletResponse参数的init方法。 I will forward the request to another servlet named ForwardedServlet.java which will display some text on the web page. 我将请求转发到另一个名为ForwardedServlet.java的servlet,它将在网页上显示一些文本。 But when i am trying to execute the ExampleServlet http://localhost:8080/Sample/ExampleServlet the following error occurs. 但是,当我尝试执行ExampleServlet http:// localhost:8080 / Sample / ExampleServlet时,会发生以下错误。


The request sent by the client was syntactically incorrect (HTTP method GET is not supported by this URL). 客户端发送的请求在语法上不正确(此URL不支持HTTP方法GET)。

Please give the solution and why it this error occured... Thanks in advance 请提供解决方案以及为什么会发生此错误...在此先感谢

You haven't implemented the 'doGet' method, so it's falling back to the default implementation, which is a 503 server error (or some variant). 您尚未实现'doGet'方法,因此它会退回到默认实现,这是503服务器错误(或某些变体)。

The init is only called once, when the servlet is instantiated - it's not called once per request, which you'll need to do. 初始化servlet时,init仅被调用一次-每个请求都不会被调用一次,您需要这样做。

Also, make sure the capitalisation and arguments are correct; 另外,请确保大写和参数正确。 if you use something else, it won't be the right method that the Servlet API calls. 如果您使用其他方法,那将不是Servlet API调用的正确方法。

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

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