简体   繁体   中英

Configuring web.xml to execute particular Page

I am having a Login.jsp page in Admin Folder. Now when ever the user access the Admin folder the Login Page should be the first to get Executed.

Below is my Directory structure for Project.

在此处输入图片说明

How to Configure in web.xml so that when i access the Admin folder Login.jsp will be executed instead of index.jsp

The contents of web.xml is as given below

<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. If this is a simple application without any framework you can simply configure all jsp pages in web.xml to map against appropriate urls. In case of using frameworks like struts you can use modules configuration.

As per your question try this.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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