私たちは、PDFの代わりに画像を返す以外、同様の何かを持っています。しかし、私は推測しています。 (私は簡素化しようとしているので、私は表示されないよすべて。)
<c:url value="/path/getImage.do?imageId=${imageID}" />
あなたのケースでは、多分:JSPオン
、我々は
src
に設定されて
IMG
タグを持っていますそれは同様の方法で
href
が行われるリンクになります。
そのgetImage.do
は明らかにJPFコントローラにマップされています。ここでは、上で動作しようとしている部分であるJPF getImage()
方法、からのコードは次のとおりです。
@Jpf.Action(forwards = {
@Jpf.Forward(name = FWD_SUCCESS, navigateTo = Jpf.NavigateTo.currentPage),
@Jpf.Forward(name = FWD_FAILURE, navigateTo = Jpf.NavigateTo.currentPage) })
public Forward getImage(final FormType pForm) throws Exception {
final HttpServletRequest lRequest = getRequest();
final HttpServletResponse lResponse = getResponse();
final HttpSession lHttpSession = getSession();
final String imageIdParam = lRequest.getParameter("imageId");
final long header = lRequest.getDateHeader("If-Modified-Since");
final long current = System.currentTimeMillis();
if (header > 0 && current - header < MAX_AGE_IN_SECS * 1000) {
lResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return null;
}
try {
if (imageIdParam == null) {
throw new IllegalArgumentException("imageId is null.");
}
// Call to EJB, which is retrieving the image from
// a separate back-end system
final ImageType image = getImage(lHttpSession, Long
.parseLong(imageIdParam));
if (image == null) {
lResponse.sendError(404, IMAGE_DOES_NOT_EXIST);
return null;
}
lResponse.setContentType(image.getType());
lResponse.addDateHeader("Last-Modified", current);
// public: Allows authenticated responses to be cached.
lResponse.setHeader("Cache-Control", "max-age=" + MAX_AGE_IN_SECS
+ ", public");
lResponse.setHeader("Expires", null);
lResponse.setHeader("Pragma", null);
lResponse.getOutputStream().write(image.getContent());
} catch (final IllegalArgumentException e) {
LogHelper.error(this.getClass(), "Illegal argument.", e);
lResponse.sendError(404, IMAGE_DOES_NOT_EXIST);
} catch (final Exception e) {
LogHelper.error(this.getClass(), "General exception.", e);
lResponse.sendError(500);
}
return null;
}
非常に少ないが、私は非表示にする必要があることをそこにありますので、私は実際に、この方法からはほとんど削除しましたこのコードは、ビジネスロジックではなく、イメージに関係するかなり一般的なものです。 (私はいくつかのデータ型名を変更しましたが、大きな問題はありません)