为什么我们使用web.xml? [英] Why do we use web.xml?

查看:116
本文介绍了为什么我们使用web.xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

web.xml有什么用?我们为什么要使用?

What is the use of web.xml and why do we use?

<filter>
        <filter-name>wicket.mysticpaste</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationClassName</param-name>
            <param-value>com.mysticcoders.WicketApplication</param-value>
        </init-param>
    </filter>

 <filter-mapping>
  <filter-name>wicket.mysticpaste</filter-name>
    <url-pattern>/*</url-pattern>
 </filter-mapping>

这个文件管理器和文件管理器有什么作用?

What does this filer and filermapping do?

推荐答案

一般来说,这是java中Web应用程序的配置文件。它指示servlet容器(例如tomcat)加载哪些类,在上下文中设置什么参数,以及如何拦截来自浏览器的请求。

Generally speaking, this is the configuration file of web applications in java. It instructs the servlet container (tomcat for ex.) which classes to load, what parameters to set in the context, and how to intercept requests coming from browsers.

在那里你指定:


  • 您要使用哪些servlet(和过滤器)以及要将它们映射到哪些URL

  • 侦听器 - 在某些事件发生时通知的类(上下文启动,会话创建等)

  • 配置参数(context-params)

  • 错误页面,欢迎文件

  • 安全constriants

  • what servlets (and filters) you want to use and what URLs you want to map them to
  • listeners - classes that are notified when some events happen (context starts, session created, etc)
  • configuration parameters (context-params)
  • error pages, welcome files
  • security constriants

在servlet 3.0中很多网页.xml部分是可选的。这些配置可以通过注释完成( @WebServlet @WebListener

In servlet 3.0 many of the web.xml parts are optional. These configurations can be done via annotations (@WebServlet, @WebListener)

这篇关于为什么我们使用web.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆