<%
String fn=session.getAttribute("fn").toString();
fn="img/"+fn;
%>
<tr>
<td width="20%" style="border-style: none; border-width: medium" height="17">
</td>
<td width="20%" style="border-style: none; border-width: medium" height="17" bgcolor="#FFFFFF">
</td>
<td width="20%" style="border-style: none; border-width: medium" height="17" bgcolor="#FFFFFF">
<img border="0" src="<%=fn%>" width="90" height="90"></td>
<td width="20%" style="border-style: none; border-width: medium" height="17">
</td>
</tr>
我正在基于先前JSP中的用户输入生成QR图像并将其显示在上面的JSP中。 QR生成在Eclipse(Mars)动态Web项目中运行良好。 Eclipse正在/ WebContent / img /文件夹中正确生成它。但是我无法使用上面的JSP显示图像。清除缓存,重新启动Tomcat6,重新启动eclipse和重新启动笔记本电脑并没有解决问题。我看到了以下错误:
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /home/amruth/workspace2/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/Banking_With_OTP2 does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4320)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4489)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jul 20, 2015 4:38:26 PM org.apache.catalina.core.StandardContext start
SEVERE: Error in resourceStart()
Jul 20, 2015 4:38:26 PM org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
Jul 20, 2015 4:38:26 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Banking_With_OTP2] startup failed due to previous errors
Jul 20, 2015 4:38:26 PM org.apache.catalina.core.StandardContext stop
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Banking_With_OTP2] has not been started
Jul 20, 2015 4:38:26 PM org.apache.catalina.core.StandardContext resourcesStart
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Document base /home/amruth/workspace2/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/temp does not exist or is not a readable directory
at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:142)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4320)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4489)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
答案 0 :(得分:0)
这个问题在日食中继续存在。所以我提取了项目的.war文件并直接在Appache Tomcat中运行它。然后它运行良好没有任何问题。这是一个很好的实用解决方案。
答案 1 :(得分:0)
您尚未向图像路径字符串添加格式。 你的jsp代码应该是:
<%
String fn=session.getAttribute("fn").toString();
fn="img/"+fn+".jpg";
%>