1

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 i.e inside the "view" folder.

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

enter image description here

Each directory (e.g. 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.

Mohsin
  • 852
  • 8
  • 28
  • That's a terrible idea. If you had two JSPs named the same way in two of thse directories, which one would it pick? Just return the complete name of the view: `"foo/bar/hello"` – JB Nizet Aug 12 '19 at 21:42

1 Answers1

0

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.

Mohsin
  • 852
  • 8
  • 28