Home  >  Article  >  Java  >  Pictures in java project cannot be displayed

Pictures in java project cannot be displayed

王林
王林Original
2020-02-03 09:29:594960browse

Pictures in java project cannot be displayed

Problem:

The picture in the java project cannot be displayed

The solution is as follows:

1. Check whether the path of the picture is If there is a problem, is an absolute path used? It is recommended to use a relative path;

Recommended learning video: java video tutorial

2. If a relative path is used and check that the path is correct , the photo still cannot be displayed. You can try adding ../dot-dot bar in front of the path, because when your page involves a jump, the path will change and the relative path will also change accordingly.

3. If your project uses the DispatcherServlet interceptor, it will also cause the image loading to fail. It is possible that all requests involving url, href, and src will fail because the interceptor is configured in the Web.xml file. , this file will be loaded and configured when the server is started. If the interception requirement is set to /intercept all, any request will be intercepted by the interceptor and will not have any effect. Only the interception requirement is set to *.do or any custom Suffix name (as long as it does not affect the suffix of the image path).

Recommended related articles and tutorials: java introductory tutorial

The above is the detailed content of Pictures in java project cannot be displayed. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn