I have an html file in my app root folder, which is located under webapp tomcat folder: apache-tomcat-9.0.0.M3\webapps\shop\index.html
when I'm trying to open http://localhost:8080/shop/
"The requested resource is not available"
occurs. I'm using spring mvc, so I'm getting the following message in terminal: No mapping for http request with URl shop/ in DispatcherServlet. Nevertheless it works fine if rename it to index.jsp
Related
I am new to GCP/SpringBoot and working on a project where I have a scenario to read a file that is present in the project directory. The below code works fine when I run it with localhost but fails with "File not Found" after deploying the Springboot application to cloudrun.
Can anyone help on how to read the file or what is the location to place the file.
InputStream is = new FileInputStream("Legend.jpg");
Intead of put the file at the root of the project, it's better to use resource files.
You can put your file in the resource folder src/main/resources/images/Legend.png
And retrieve it in the jar as follow :
InputStream stream = ResourceUtil.class.getClassLoader().getResourceAsStream("images/Legend.png");
You can also check this topic to have more explanations on different ways of retrieving files from resource folder.
When creating a tomcat app service I create subfolders in webcontent and their path is created accordingly. Example tree:
Webcontent:
index.jsp
folder1:
page.jsp
To access page.jsp url I type: website.com/folder1/page.jsp
This all works as expected in localhost on any tomcat version, however when I deploy it to azure app service Tomcat v9.0.62 page.jsp is mapped to root: website.com/page.jsp
If I downgrade to tomcat v9.0.54 it works as expected.
I'd really appreciate any help in figuring out how to fix this behavior when deployed
In my spring application after upgrading to tomcat8 response header location is become relative path. Can i know which file should i config for changing it back to absolute path.
As we are using nginx server and alb in our application. relative path response returning 404 page in nginx url were it is working fine in alb .
Set <Context useRelativeRedirects="false"> in context.xml of tomcat folder.
Reference :
https://tomcat.apache.org/tomcat-8.5-doc/config/context.html
I already installed URL rewrite and made a web.config file for my angular application. But when I browse the site from my localhost the below error appears:
Currently, the default url for my sample application is:
http://127.0.0.1:8080/SpringMVC/
Is it possible for my to access it through below url ?
http://127.0.0.1:8080/
How can this be done ?
rename the war file to ROOT.war . Then delete (or rename) the default ROOT tomcat directory and start tomcat.