Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot does not load jsp file

Using spring boot starter 2.4.1 version.

resources folder has the following structure. As it is seen hello.jsp is in templates folder. These are included in application.properties:

  spring.mvc.view.prefix=/templates/
  spring.mvc.view.suffix=.jsp

And a simple controller:

@Controller
public class HelloController {
    @GetMapping("/hello")
    public String index(){
        return "hello";
    }
}

But get 404.

Controller method is entering for sure.

Tried what is suggested in the following answer, tried using the webapp, but didn't help: /WEB-INF is not created inside target at all, it seems maven is ignoring webapp and WEB-INF folders.

target

like image 342
Serob_b Avatar asked Mar 22 '26 02:03

Serob_b


1 Answers

Just restarting Inellij IDEA with invalidating caches (File | Invalidate Caches / Restart) solved the problem.

Actually it started to work with templates folder, so templates are the root, and if you put something inside it, you can access from controllers without any prefix setting.

But again nothing is workable from webapp, seams maven is ignoring webapp at all. Maybe this is connected with maven, or spring-boot version.

And add thymeleafe dependency and it will work with .html files (this is not the thing I like, but up to now the only workable solution found).

like image 70
Serob_b Avatar answered Mar 24 '26 16:03

Serob_b



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!