iteye_13253 2010-07-08 16:01
浏览 253
已采纳

tomcat是如何实现ServletConfig接口的, 在什么地方可以查看到源代码?

我对ServletConfig接口的实现一直比较迷茫,想通过了解tomcat是如何对它做出实现来进一步认识ServletConfig.
[color=darkred][b]在构建一个servlet的时候需要容器提供一个ServletConfig对象,这个servletConfig对象的代码是如何实现的呢?主要就是servletConfig中的几个方法的实现代码!如果有地方可以查看源码,那是最好不过了![/b][/color]

查看servlet API相关信息如下:

javax.servlet Interface ServletConfig 有如下方法:

[color=blue][b]String getInitParameter(String name)[/b][/color]
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
[color=blue][b]Enumeration getInitParameterNames() [/b][/color]
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.
[color=blue][b]ServletContext getServletContext() [/b][/color]
Returns a reference to the ServletContext in which the caller is executing.
[color=blue][b]String getServletName() [/b][/color]
Returns the name of this servlet instance

javax.servlet Interface Servlet 有如下几个方法:

[color=blue][b] void destroy()[/b][/color]
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service.
[color=blue][b]ServletConfig getServletConfig() [/b][/color]
Returns a ServletConfig object, which contains initialization and startup parameters for this servlet.
[color=blue][b] String getServletInfo() [/b][/color]
Returns information about the servlet, such as author, version, and copyright.
[color=blue][b] void init(ServletConfig config) [/b][/color]
Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
[color=blue][b] void service(ServletRequest req, ServletResponse res) [/b][/color]
Called by the servlet container to allow the servlet to respond to a request.

  • 写回答

3条回答 默认 最新

  • 普通网友 2010-07-15 10:11
    关注

    兄弟 英文好吗?英文好并且有时间的话 建议你看看How Tomcat Works这本书,完全教你Tomcat工作原理以及里面各个组件的分析

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料