当前位置: 代码迷 >> J2EE >> Servlet接口的service()方法解决方案
  详细解决方案

Servlet接口的service()方法解决方案

热度:453   发布时间:2016-04-22 03:20:45.0
Servlet接口的service()方法
红色部分我不懂是什么意思,望高手翻译一下,能翻译多少就翻译多少,先谢谢。
void service(ServletRequest req,
  ServletResponse res)
  throws ServletException,
  IOException
方法说明:
Called by the servlet container to allow the servlet to respond to a request. 
This method is only called after the servlet's init() method has completed successfully. 

The status code of the response always should be set for a servlet that throws or sends an error. 

Servlets typically run inside multithreaded servlet containers that can handle multiple requests concurrently. Developers must be aware to synchronize access to any shared resources such as files, network connections, and as well as the servlet's class and instance variables.

------解决方案--------------------
1) 对于抛异常或发送错误的servlet, 始终需要设置repsonse的状态值.
2) 开发者必须要知道同步访问共享的资源, 比如....
3) 以及servlet的类变量和实例变量




代码迷推荐解决方案:Servlet.service() for servlet default threw exception,http://www.daimami.com/search?q=181756
  相关解决方案