gpt4 book ai didi

java - 检索存储在 Zk Tomcat 文件夹中的图片

转载 作者:行者123 更新时间:2023-12-02 05:47:09 25 4
gpt4 key购买 nike

我是 zk 编程的新手,我已将应用程序中的图片存储到服务器(tomcat)外的一个文件夹中,我想检索它,该文件夹是 c:\temps ,假设图片名称是 myPic.jpg当我写 pics.setSrc("c:\temps\myPic.jpg"); 时它对我不起作用我能做些什么来修复它存储非常好但检索图片仅在 Eclipse IDE 上工作但在其他浏览器中它不起作用

@Wire
private org.zkoss.zul.Image pics;
private static final String SAVE_PATH = "C:\temps\";
private ProfileDao pd = new JpaProfileDao();
private ListModel<profile> profileModel;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
profileModel = new ListModelList<Profile>(pd.findAll());
prfileSelect.setModel(profileModel);
String src="C://tmp//testimg.jpg";
pics.setSrc(src);
Clients.showNotification(pics.getSrc());
}

在浏览器中我遇到这些问题

Not allowed to load local resource:file:///C://temps//testimg.jpg

最佳答案

您正在尝试访问服务器端的文件,服务器不知道您的光盘所以使用 tomcat 的别名

       <Context crossContext="true" docBase="here_the_path_in_disc" path="project_name/resource_name" reloadable="true"/>

关于java - 检索存储在 Zk Tomcat 文件夹中的图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23954543/

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