GlassFish 4.1 alternatedocroot,访问静态内容 [英] GlassFish 4.1 alternatedocroot, Access static contents
问题描述
我需要使用此网址访问一些图片 http:// localhost:8080 / static / img1.jpg
图像位于/ home / andrea / Documents中,应用程序上下文为/。我使用GlassFish 4.1.1。
$ b 在项目的/ WEB-INF目录中,我已经得到以下内容:(glassfish-web.xml)
<?xml version =1.0encoding =UTF-8?>
<!DOCTYPE glassfish-web-app PUBLIC - // GlassFish.org //DTD GlassFish Application Server 3.1 Servlet 3.0 // ENhttp://glassfish.org/dtds/glassfish-web-app_3_0 -1.dtd>
< glassfish-web-app>
< parameter-encoding default-charset =UTF-8/>
< property name =alternatedocroot_1value =from = / static / * dir = / home / andrea / Documents/>
< / glassfish-web-app>
问题是,文件没有找到。
我做了什么miss?
有没有另外一种方法来定义alternatedocroot`或者映射项目外的虚拟目录?
我已经解决了阅读这篇文章的问题: http://glassfish.10926.n7.nabble.com/unable-to-get-working-alternate-docroots-td40978.html
不幸的是,文档不太清楚,我尝试解释我是如何解决问题的。
dir 值是 alternatedocroot 的基础目录,因此您必须将 中指定的完整路径指定到alternatedocroot的基本目录中。因此,在我的情况下,真正的结构是 / home / andrea / Documents / static (请记住在 dir 值的末尾插入/)。 b
$ b
glassfish-web.xml
<?xml version =1.0encoding = UTF-8 >?;
<!DOCTYPE glassfish-web-app PUBLIC - // GlassFish.org //DTD GlassFish Application Server 3.1 Servlet 3.0 // ENhttp://glassfish.org/dtds/glassfish-web-app_3_0 -1.dtd>
< glassfish-web-app>
< parameter-encoding default-charset =UTF-8/>
< property name =alternatedocroot_1value =from = / static / * dir = / home / andrea / Documents //>
< / glassfish-web-app>
My exigence
我的目标是有一个单独的目录来上传从.war存档分离的图像。我找到的解决方案是将图像插入到glassfish domain1目录的docroot目录中。
$ b
glassfish-web.xml
<?xml version =1.0encoding =UTF-8?>
<!DOCTYPE glassfish-web-app PUBLIC - // GlassFish.org //DTD GlassFish Application Server 3.1 Servlet 3.0 // ENhttp://glassfish.org/dtds/glassfish-web-app_3_0 -1.dtd>
< glassfish-web-app>
< parameter-encoding default-charset =UTF-8/>
< / glassfish-web-app>
请记住,真实路径必须包含静态目录:[...] / glassfish / domains / domain1 / docroot / static /
I need to access some images with this URL http://localhost:8080/static/img1.jpg
The images are in "/home/andrea/Documents", the application context is "/". I'm using GlassFish 4.1.1.
In the /WEB-INF directory of project I've got the following: (glassfish-web.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<parameter-encoding default-charset="UTF-8" />
<property name="alternatedocroot_1" value="from=/static/* dir=/home/andrea/Documents" />
</glassfish-web-app>
The problem is that, the file is not found.
What did I miss?
Is there another way to define alternatedocroot` or map a virtual directory outside the project?
I've resolved the problem reading this post: http://glassfish.10926.n7.nabble.com/unable-to-get-working-alternate-docroots-td40978.html
Unfortunately the documentation is not so clear, I try to explain how I solved my problem
The dir value is the base directory of your alternatedocroot, so you must put full path specified for the value frominto the base dir of alternatedocroot. Therefore in my case the real structure is /home/andrea/Documents/static (Remember to insert "/" at the end of dir value).
glassfish-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<parameter-encoding default-charset="UTF-8" />
<property name="alternatedocroot_1" value="from=/static/* dir=/home/andrea/Documents/" />
</glassfish-web-app>
My exigence
My exigence is to have a separate directory to upload images separated from the ".war" archive. The solution I've found is insert the images in docroot directory of glassfish domain1 directory
glassfish-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<parameter-encoding default-charset="UTF-8" />
<property name="alternatedocroot_1" value="from=/static/* dir=./docroot/" />
</glassfish-web-app>
Remember that the real path must contain static directory: [...]/glassfish/domains/domain1/docroot/static/
这篇关于GlassFish 4.1 alternatedocroot,访问静态内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!