Static jsp content is not shown

Asked

Viewed 1,115 times

2

I’m using netbeans 7.3.1, apparently it’s working ok. Pages are opening normally, but when I try to access css content, jpg, ... within the Resources folder, no content appears.

In the file Dispatcher-Servlet.xml I put the following line:

<mvc:resources mapping="/resources/**" location="/resources/" />

and at index.jsp, I put the call as follows: <link rel="stylesheet" href="resources/css/style.css" type="text/css"/>

organização do sistema

Could someone help me?

2 answers

1

Problem has been solved.

The question was where the Sources folder was, for some reason, as "utluiz" had mentioned, it was not in the correct place, because it was another folder. Then I created a "Resources" folder in the "web app" folder as follows inserir a descrição da imagem aqui

He did not need to perform any mapping in "Dispatcher-Servlet.xml". Therefore, the lines he had placed were removed

Thank you!

0

First you put the images and styles in a directory of resources. Although it’s the same name you’re using, it’s not the same.

Note that the top element title is "Other Source Codes". These resources are actually used in the Java application as configuration files.

The correct location for the styles and images is within "Web Pages".

Assuming you move the two folders into "Web Pages", I suggest changing your annotation as follows:

<mvc:resources mapping="/img/**" location="/img" />
<mvc:resources mapping="/css/**" location="/css/" />

Note that the attribute location refers to the root of the application, which is "Web Pages". In fact, if Netbeans is following the Maven structure, this folder is src/main/webapp, but it ends up hiding the real site. This is the site that should receive the resources of the webapp.

  • Thank you so much for your help! Unfortunately I still have the same problem. I put the folders in the webapp (yes it is following the structure of the Maven); I replaced the following code in the file Dispatcher-Servlet.xml <mvc:resources mapping="/img/**" location="/img/" />&#xA; <mvc:resources mapping="/css/**" location="/css/" /> , and I made a simple call to jsp to check if the image was showing <img src="img/calendario.jpg" /> Is something missing? Sorry for the hassle. I’m new to spring MVC :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.