我正在将图像上传到服务器,当图像上传时,它应该向我显示上传图像的拇指.缩略图未保存在硬盘上我使用InputStream和OutputStream.对于上传我是ustig tomahawk.
我的index.jsp:
<h:form id="uploadForm" enctype="multipart/form-data">
<t:inputFileUpload id="fileupload"
accept="image/*"
storage="file"
value="#{fileUpload.uploadedFile}"
styleClass="fileUploadInput"
required="true"
validator="epacient.FileUploadValidator"
requiredMessage="Obvezna izbira datoteke."
/>
<br />
<h:message for="fileupload" infoStyle="color: green;"
errorStyle="color: red;" />
<br />
<h:commandButton value="Upload" id="fileUploadButton"
action="#{fileUpload.upload}" />
<h:message for="uploadForm" style="color: red;" />
<h:graphicImage value="#{fileUpload.thumb}"
rendered="#{fileUpload.uploaded}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)
fileUpload.upload调用函数 String preview()
private String thumb ;
public String preview() throws IOException{
HttpServletResponse response = (HttpServletResponse)FacesContext
.getCurrentInstance().getExternalContext().getResponse();
try {
FacesContext context = FacesContext.getCurrentInstance();
Map requestMap = context.getExternalContext().getApplicationMap();
byte[] bytes = (byte[])(requestMap.get("fileupload_bytes"));
// returns byte[]
byte[] testByte …Run Code Online (Sandbox Code Playgroud) 如果注册用户跳转到login.jsp我希望将其重定向到youAreLoggedIn.jsp.这可以用<navigation-rule>吗?我知道如何在PHP中执行此操作,但不在JSP中执行此操作.当用户访问时login.jsp,必须检查用户是否已登录,我知道如何检查.但是如何触发这个动作呢?我应该制作一个新的servlet还是什么?
谢谢!