简体   繁体   中英

Spring Boot MVC - How to configure multipe view directories in application.properties

I am trying my hands on Spring MVC Boot application and I am currently using springBootVersion = '2.1.6.RELEASE'.

I have hundreds of ".jsp" files placed in multiple sub-directories which are inside a "view" directory of my web application and i am trying to see how i can define the property in application.properties file to search for the jsp files in all sub directories rather than only view directory.

Currently the application is able to find the jsp pages only if they are located outside the sub folders ie inside the "view" folder.

Below is the screenshot of my project directory structure and the application.properties file.

在此处输入图片说明

Each directory (eg be, ca, de, fr) has its own jsp pages, images, css, js etc.

I have tried with the following 3 property values but it did not work -

spring.mvc.view.prefix:/WEB-INF/

spring.mvc.view.prefix:/WEB-INF/*/

spring.mvc.view.prefix:/WEB-INF/view/*/ 

Please advise if there is a way to search for the jsp files in all sub directories.

Documenting the answer so others can benefit. After some trail and error I found a easy way -

Kept the property value in application.properties file as below -

spring.mvc.view.prefix:/WEB-INF/view/

In the controller method, i am simply adding the subfolder name before the jsp page name like below -

@RequestMapping("/Test")
        public String TestPage(Map<String, Object> model) {
         logger.info("Redirecting to Test Page");
            model.put("message", "You are in Test page !!");
            return "be/TestPage";
        }

It is now able to find the jsp page inside "view" folder sub directories.

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