简体   繁体   English

图形未显示在jsp上

[英]graphics are not shown on jsp

in my application all jsp pages in jsps folder i give the path in index.jsp: <% response.sendRedirect(response.encodeRedirectURL("/Projectname/jsps/main.jsp")); %> 在我的应用程序中,我在jsps文件夹中的所有jsp页面中都给出了index.jsp中的路径: <% response.sendRedirect(response.encodeRedirectURL("/Projectname/jsps/main.jsp")); %> <% response.sendRedirect(response.encodeRedirectURL("/Projectname/jsps/main.jsp")); %> although main.jsp is show but it does not show logo, graphics etc. all the js and logo files in js folder which is parallel to jsps and WEB-INF folders. <% response.sendRedirect(response.encodeRedirectURL("/Projectname/jsps/main.jsp")); %>尽管显示了main.jsp,但它不显示徽标,图形等。js文件夹中的所有js和徽标文件与jsps和WEB-INF文件夹平行。 now structure is: ProjectName>WebContent>Company1,WEB-INF,index.jsp,jsps>here all jsp's 现在的结构是:ProjectName> WebContent> Company1,WEB-INF,index.jsp,jsps>这里所有的jsp

in Company1 folder having some CSS file.but graphics are not shown. 在Company1文件夹中有一些CSS文件。但是未显示图形。 it work fine when all jsp's was in Company1 folder. 当所有jsp都位于Company1文件夹中时,它工作正常。

"Graphics" as you call it (images, CSS, etc), are not loaded in webserver, but in webbrowser by a simple HTTP request. 所谓的“图形”(图像,CSS等)未通过Web服务器加载,而是通过简单的HTTP请求加载在Web浏览器中。 Relative URL's are relative to the current request URL (as you see in browser address bar), not to the folder structure in the server side. 相对URL是相对于当前请求URL的(如您在浏览器地址栏中看到的),而不是相对于服务器端的文件夹结构。

In order to figure the correct relative URL, you need to know the absolute URL of both the JSP page and the image file. 为了找到正确的相对URL,您需要知道JSP页面和图像文件的绝对URL。 For example http://example.com/jsps/page.jsp and http://example.com/images/image.gif . 例如http://example.com/jsps/page.jsphttp://example.com/images/image.gif In that case, the relative URL to the image as opposed from the JSP page would be one folder up and then the filename: ../images/image.gif Alternatively you can also use a domain-relative URL, starting with a leading slash: /images/image.gif . 在这种情况下,与JSP页面相对的图像的相对URL将是一个文件夹,然后是文件名: ../images/image.gif或者,您也可以使用相对于域的URL,以反斜杠开头: /images/image.gif

If you're using CSS background images like selector { background: url('foo.gif'); } 如果您使用CSS背景图片,例如selector { background: url('foo.gif'); } selector { background: url('foo.gif'); } , then you need to know that those URL's are relative to the URL of the CSS file itself, not to the JSP page which is including the CSS file. selector { background: url('foo.gif'); } ,那么您需要知道这些URL是相对于CSS文件本身的URL,而不是相对于包含CSS文件的JSP页面。

If you can't get it to work, update your question to include the absolute URL of both the JSP page and the image file, then we can assist you in extracting the correct relative URL. 如果您无法使用它,请更新您的问题以包括JSP页面和图像文件的绝对URL,然后我们可以帮助您提取正确的相对URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM