How to create dynamic images with struts2?

In strut2, the tag is <s:img>

gone. How do I create dynamic images?

Update

I want to set the 'src' image according to a parameter on the value stack (eg $ {userName _}).

+2


a source to share


2 answers


I did a search on struts2 official website and found that they do not provide a dynamic image tag. There is a struts2 plug that provides this, however it is in alpha stage. http://code.google.com/p/s2-image/ . Finally, I had to do it in pure JSP codes.



Updating Gash ... There is another easy way using <img src=<s:text name="genTP" /> />

. But I think this is rather strange.

+3


a source


No specific tag needed. You just use a simple html tag <img src="...">

, an attribute src

pointing to a static / dynamic url that gives you an image.

Now, if the url points to an action in the same Struts2 web application, you need to code the action that returns a dynamic image instead of an html page. In this case, you should read about the stream result ... if you can find anything useful on the official page / wiki (sigh ... The docs are messed up at this point, do yourself a favor and buy "Struts2 in Action"). The concept is pretty clean once you understand it. See for example:



http://www.javahowto.net/struts2/dynamic-mime-type-on-stream-result-struts-2/

+1


a source







All Articles