开发者

Image parameter in JSP

开发者 https://www.devze.com 2023-03-04 16:01 出处:网络
Hy! My site calling: http://localhost:8080/WebTest/index.jsp?image=1.JPG Code: <img src=<% request.getParamet开发者_StackOverflow中文版er(\"image\");%>alt=\"1\"/>

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}" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号