Image parameter in JSP
Hy!
My site calling:
http://localhost:8080/WebTest/index.jsp?image=1.JPG
Code:
<img src=<% request.getParamet开发者_StackOverflow中文版er("image");%> alt="1"/>
The problem is that no image is shown. The image is the right parth.
This is working:
<img src="1.JPG" width="3872" height="2592" alt="1"/>
Please help
The <% %>
won't print anything. Use <%= %>
to print something.
<img src=<%= request.getParameter("image") %> alt="1" />
It's safe to put quotes around the attribute value
<img src="<%= request.getParameter("image") %>" alt="1" />
But much better is to just use EL instead of the since a decade discouraged scriptlets:
<img src="${param.image}" alt="1" />
It's better to use
<img src="${param.image}" />
精彩评论