0

I am trying to build a weather Scraper website using Spring MVC. For now, i am trying to make the design of the website. When, i try to insert a background image for this design, it does not seem to appear when i check out the URL(http://localport:8080/weatherScraper). However, the rest of the elements appear as expected.

My Controller class:

public class Controller {

@RequestMapping(value = "/weatherScraper", method = RequestMethod.GET)
public String webpageGet(ModelMap modelMap){
    return "Mainpage";
}

}

My MainPage.html

I saved the image as weather.jpg. I even tried <body background = "weather.jpg" and <body style="background-image:url("weather.jpg")" and I tried a lot of other different ways but it still did not work for me. Can someone help me out on this please?

abdv19
  • 5
  • 4
  • Refer to the link, it can help you https://stackoverflow.com/questions/20369529/display-image-in-jsp-with-spring-mvc/20369698 – Ahmad Qureshi Jun 14 '21 at 21:59
  • The link you sent above suggests that i add to the mvc configuartion but what exactly does mvc configuration mean? In which file do i exactly put this? – abdv19 Jun 15 '21 at 06:03
  • In your spring mvc application, there will be a web.xml, Refer spring documentation – Ahmad Qureshi Jun 15 '21 at 10:52
  • i dont have a web.xml – abdv19 Jun 15 '21 at 18:30
  • Refer https://stackoverflow.com/questions/14861720/annotation-configuration-replacement-for-mvcresources-spring for java based configuration – Ahmad Qureshi Jun 15 '21 at 19:29
  • Nothing seems to work for me, i created the webmvc configuartion class and added @Override public void addResourceHandlers(final ResourceHandlerRegistry registry) { registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); } ...... i even added in my html file but nothing works. Please help me with this asap – abdv19 Jun 16 '21 at 07:00
  • Have you added weather3.jpg to your resources folder in your project – Ahmad Qureshi Jun 16 '21 at 13:00
  • Yes i have added weather3.jpg in a directory called images in rthe resources folder – abdv19 Jun 16 '21 at 17:30
  • I've literally tried everything possible but nothing seems to work for me. Can someone please help. – abdv19 Jun 17 '21 at 03:25

0 Answers0