• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

[Spring]Get images from external resources: Issue with @EnableWebMvc and WebMvcConfigurationSupport

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created a spring boot application and I am trying to get images from external folder on disk, here is my code:



But when I launch the application, I got this error message:

> o.s.web.servlet.PageNotFound: No mapping for GET /myapp/index
> o.s.b.w.servlet.support.ErrorPageFilter  : Cannot forward to error
> page for request [/] as the response has already been committed.



Even if I remove @EnableWebMvc and I extend WebMvcConfigurationSupport directly, I am getting the same issue.

 1.  Why am I getting this issue?

 2. Is it possible to get images from external resources without using @EnableWebMvc or WebMvcConfigurationSupport?

Thanks
 
Bartender
Posts: 653
14
TypeScript Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
where is myapp/index coming from?  I don't see that in the code.
 
Deparis Momo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my WelcomeController Class:



And my spring security Class:

 
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Deparis,
What is your project structure?
You may need to put the images under webapp folder and see if that works first.
Reference:
https://stackoverflow.com/questions/37240513/o-s-boot-context-web-errorpage-cannot-forward-to-error-page-for-request-as
 
Deparis Momo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I resolved the problem. Firstly I removed @EnableWebMvc and WebMvcConfigurationSupport, then I noted that there was an issue in the url. I put :



Instead of:



As I am a Windows user.

Thanks
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your file location seems incorrect , you can handle it in multiple ways . Put file inside resources if yes then it works absolutely fine , but with external folder please check permissions i had an issue while i was running with different permission.
Have  a look at this link on few of the possible ways to handle static content in spring boot applications.
https://www.frugalisminds.com/spring-boot-serve-static-web-content/

Please check the spring boot version as well it should be higher than 2.0 .
 
reply
    Bookmark Topic Watch Topic
  • New Topic