gpt4 book ai didi

image - PrimeFaces imageCropper 不显示可选区域

转载 作者:行者123 更新时间:2023-12-01 06:33:44 25 4
gpt4 key购买 nike

我只是复制了 primefaces 展示上的示例,但未显示选择图像的区域。在陈列柜中,它看起来如此简单。

我的页面:

<ui:composition 
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">

<h:form>

<p:imageCropper value="#{uploadMB.croppedImage}" id="imageCropper"
image="/images/banner.jpg" />


</h:form>

</ui:composition>

我的背 bean :
@ManagedBean
public class UploadMB implements Serializable{

private static final Logger logger = Logger.getLogger(UploadMB.class.getName());

private CroppedImage croppedImage;
private String newImageName;

public String crop() {
if(croppedImage == null)
return null;

setNewImageName(getRandomImageName());
ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
String newFileName = servletContext.getRealPath("") + File.separator + "images" + File.separator + "barca" + File.separator + getNewImageName() + ".jpg";

FileImageOutputStream imageOutput;
try {
imageOutput = new FileImageOutputStream(new File(newFileName));
imageOutput.write(croppedImage.getBytes(), 0, croppedImage.getBytes().length);
imageOutput.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

return null;
}

private String getRandomImageName() {
int i = (int) (Math.random() * 100000);

return String.valueOf(i);
}

public String getNewImageName() {
return newImageName;
}

public CroppedImage getCroppedImage() {
return croppedImage;
}

public void setCroppedImage(CroppedImage croppedImage) {
this.croppedImage = croppedImage;
}

public void setNewImageName(String newImageName) {
this.newImageName = newImageName;
}

是否可能缺少一些库?或其他配置选项?我刚刚下载了 primefaces 3.5 jar 并将其放入我的类路径中。

谢谢

最佳答案

您的图片位于 %WEBAPP_ROOT%/images/banner.jpg

您可以通过 HTTP Url(浏览器)访问您的图片吗?

关于image - PrimeFaces imageCropper 不显示可选区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17242917/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com