简体   繁体   English

配置web.xml以执行特定页面

[英]Configuring web.xml to execute particular Page

I am having a Login.jsp page in Admin Folder. 我在管理文件夹中有一个Login.jsp页面。 Now when ever the user access the Admin folder the Login Page should be the first to get Executed. 现在,无论何时用户访问Admin文件夹,登录页面都应该是第一个被执行的用户。

Below is my Directory structure for Project. 以下是我的Project目录结构。

在此处输入图片说明

How to Configure in web.xml so that when i access the Admin folder Login.jsp will be executed instead of index.jsp 如何在web.xml中进行配置,以便在我访问Admin文件夹时将执行Login.jsp而不是index.jsp

The contents of web.xml is as given below web.xml的内容如下所示

<display-name>RealCMS</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

First of all as I think you shouldn't provide direct access to user for your admin folder. 首先,我认为您不应该为您的管理员文件夹提供直接访问用户的权限。 Rather than doing this you can do mapping for all jsp pages in admin folder. 无需执行此操作,而是可以对admin文件夹中的所有jsp页面进行映射。 If this is a simple application without any framework you can simply configure all jsp pages in web.xml to map against appropriate urls. 如果这是一个没有任何框架的简单应用程序,则可以简单地将web.xml中的所有jsp页面配置为映射到相应的url。 In case of using frameworks like struts you can use modules configuration. 如果使用诸如struts之类的框架,则可以使用模块配置。

As per your question try this. 根据您的问题尝试此操作。

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>login.jsp</welcome-file>
</welcome-file-list>

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

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