mercredi 18 février 2015

How to pass parameters to servlet using SPeL

I am writing a servlet that reads images stored as byte arrays from database and outputs to view using h:graphicImage. I am using JSF 1.2.


Currently my h:graphicImage looks like this:



<h:graphicImage value="/image?id={#good.id}" alt="Image Not Found"/>


In my ImageServlet class I have this line:



String goodId = request.getParameter("id");


So I pass id parameter from JSF view to request I guess, and then perform Image search using Dao to retrieve byte array image from the database. However, goodId gets a value of '{' and not an Id of type Long which I expect. If i hardcode good's id into JSF view like this:



<h:graphicImage value="/image?id=17" alt="Image Not Found"/>


everything works and the image is being displayed from good which id is '17'. So my question is why can't I use SPeL to pass dynamic parameter?:/


Aucun commentaire:

Enregistrer un commentaire