I'm trying to write a Spring Boot Application that is capable of using ModelAndView to send out JSP files back to the caller.
Here is a Controller Method:
@Controller
public class ExampleController
{
@GetMapping("/login")
public ModelAndView getAuthPage(@RequestParam Map<String, String> params)
{
System.out.println("In Login mapping!");
ModelAndView view = new ModelAndView();
view.setViewName("login");
ModelMap models = view.getModelMap();
models.addAttribute("message", "Log In");
System.out.println("Returning View!");
return view;
}
}
I'm able to get that Method to Return.
Here are three of the fields in application.properties
spring.mvc.view.prefix=/templates/
spring.mvc.view.suffix=.jsp
spring.thymeleaf.enabled=false
Here is a list of some of the places I've attempted to store the login.jsp file:
src/main/resources/templates (only place where I could see them in the jar file)
src/webapp
src/webapp/WEB-INF/views
Looking at some of the --debug output and this Stack Overflow Question, the App seems to be looking in a folder called META-INF/resources . While there is a META-INF folder in the Jar, there is no META-INF/resources folder.
If the app is looking for .jar/META-INF/resources.login.jsp , is there a way, using Gradle, to ensure those jsp files are there. Otherwise, is there a way to have the app look for those JSP files in the .jar/BOOT-INF/classes/templates/ which is where I currently am able to get those JSP files to in the JAR?
Right now, I just want the file to be detected (within the JAR) when the controller method returns so that my client doesn't get a 404 Not Found
Note: I am aware of this question but the solution presented is to create a war instead of a jar and as of right now, I see that as a last resort type of solution.