I've made some thymeleaf templates and want to use it with Spring Boot (on Tomcat) and the only location inside a project where I can find a .html file from browser is src/main/resources/static. When I place a file there, I can access it with contextRoot/filename.html. But when I place it inside src/main/resources/templates folder, I cannot access it with neither of this: root/filename.html, root/resources/filename.html. What's the problem here?
Problem was that I didn't have Spring Boot Thymeleaf Starter dependency in the POM. I had plain Thymeleaf dependency not intended for Spring Boot and using it needed more configuration unlike the first one that works out of the box.
Related
I have a rest API written in Spring Boot that has to be deployed on a weblogic server on Unix. I have some property files and DRL files in src/resources folder. I want to place all these files on a Unix location and access them in my application. Is there a way to do this ?
When you want Spring to look outside the project folder you want:
"file:/Users/username/MyDirectory/file.txt"
I am using Spring MVC to create my WebSite.
But I dont understand how/where put my resources if I want to used application.properties instead of xml configuration.
I have enable #EnableAutoConfiguration tag in my project.
I have this project structure.
I'm using JSP like this:
<img src="/images/logo-ack.png" style="width: 60%;">
How I can access to this resources setting the path on application.properties?
You can use Spring initializr for this, because it will starts a project with structure offered by Spring. The website is https://start.spring.io/
So I'm developing in IntelliJ a spring boot app. Using Gradle, I'm creating the sprint boot jar file.
I'm having problems figuring out where to put the jsps and static content such as .js files in such a way that running the jar AND running from within IntelliJ works!
It seems that in order to get SpringBoot to find jsps in a jar file I need to put the jsps inside a src/main/resources/META-INF/resources directory. For example, META-INF/resources/WEB-INF/index.jsp. I'm pretty sure the WEB-INF is now meaningless.
However, if I try to run this spring boot app from within IntelliJ, it cannot find the jsp. 404, blah blah blah. I actually have to put the jsps in the war-style webapp directory in src/main. However that directory is totally ignored during the spring boot jar build.
So.. how do developers set up their development environments that is both IntelliJ and, say, gradle bootRun friendly?
There is a guide here which should work both in IntelliJ IDEA and in the command line via the war file which can be executed as a jar (via java -jar).
As per spring boot there are Limitations when it comes to jsp's.
To overcome these limitations we need to have the configuration made in the application to render jsp by placing the jsp's under src/main/resources/META-INF/resources/WEB-INF/jsp folder.
Sample Code: Click Here
References:
https://dzone.com/articles/spring-boot-with-jsps-in-executable-jars-1
https://github.com/hengyunabc/spring-boot-fat-jar-jsp-sample
In my Spring Boot project I cannot get static resources such as css, images and java script file via web browser. Where is proper place to put whole bootstrap dictionary, or how to configure to get desired resources?
Just create static folder in src/main/resources here: https://github.com/bajdekm/MailingHero/tree/master/src/main/resources and place them all there. If you don't create controller with mapping to root resource (something like #RequestMapping("/")), spring boot will serve static content from index.html automatically.
Here is relevant section of Spring Boot documentation.
I am using Spring/Spring Boot/and Ember. I want to put my index.html file in the "localhost" main folder, but I have no idea how the Spring Tool Suite deploys Spring Boot. What is the normal process for HTML development and accessing a Spring REST server without getting Cross Site Scripting errors?
My folder structure is as follows:
/.settings
/BookingClient
/gradle
/html (this is where my index.html, css, and all Ember related JS stuff is)
/node_modules
/src
/target
I am guessing its somewhere in the /target directory but nothing I have tried has worked.
Spring Boot will serve static resources for you. Simply put them in src/main/resources/static. See the documentation on static content for more information.