简体   繁体   English

Servlet3.0环境中的web.xml文件在哪里?

[英]Where is the web.xml file in Servlet3.0 enviroment?

I'm looking for the web.xml file in a Servlet 3.0 enviroment. 我正在Servlet 3.0环境中寻找web.xml文件。 The reason is because I want to change my welcome file from "index.jsp" to "hello.jsp". 原因是因为我想将欢迎文件从“ index.jsp”更改为“ hello.jsp”。

I know that in the web.xml file, there is a welcome-file-list, and I want to change this setting so that the index.jsp URL mapping is changed to hello.jsp. 我知道在web.xml文件中有一个welcome-file-list,并且我想更改此设置,以便将index.jsp URL映射更改为hello.jsp。

So, my question is, where is the web.xml file, or if there is no such file in Servlet 3.0, how can I change my URL mapping? 所以,我的问题是,web.xml文件在哪里,或者如果Servlet 3.0中没有这样的文件,该如何更改我的URL映射?

I would be very pleased to get the answer this question, thanks. 谢谢,我很高兴得到这个问题的答案。

对于Servlet 3.0,并非总是需要它,因此,如果不存在它,则可以在WEB-INF/web.xml添加一个

创建servlet时由您自己创建web.xml文件

In Servlet 3.0 web.xml file can be Omitt . Servlet 3.0 web.xml文件可以是Omitt。

Immediate question is Then how to map ?? 紧迫的问题是然后如何映射?

Like below using Annotations . 像下面那样使用Annotations

 @WebServlet(name = "MyServlet",
  urlPatterns = {"/myservlet"}, 
  initParams = {@WebInitParam(name="param1", value="value1")}
 )
 public MyServlet extends HttpServlet
 {

If you want to add welcome file and 400 ,500 status code exceptions ...blah blah .. 如果要添加welcome file和400,500个状态代码例外...等等等等..

Create one with path WEB-INF/web.xml and give there . 创建一个路径为WEB-INF/web.xml然后在其中给出。

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

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