我是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
答案 0 :(得分:2)
您尝试访问服务器端的文件,服务器不了解您的光盘 所以使用tomcat的别名
<Context crossContext="true" docBase="here_the_path_in_disc" path="project_name/resource_name" reloadable="true"/>
答案 1 :(得分:0)
我还没有和ZK合作过一段时间,但我很确定你需要给它一个相对于你的webapp根目录的URL。所以像&#34; /images/testimg.jpg"或像#34; https://www.google.dk/images/srpr/logo11w.png&#34;这样的规范网址,就像你写HTML一样。
答案 2 :(得分:0)
最佳方法是在Glassfish上使用alternativedocroot
或在Tomcat上使用aliases
选项 - aliases