我正在尝试从proyect工作文件夹(使用JSF 2和Netbeans IDE 7.2)获取我的页面资源和上传文件,因此我不知道如何访问它们,所以我开始阅读如何操作它和我发现了“alternatedocroot”......我一直试图让它工作创建glassfish-web文件(因为它没有被创建)并且将属性放到我的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 error-url="">
<property name="alternatedocroot_1" value="from=/images/* dir=d:/Plataforma_RAQ-Recursos/3D" />
</glassfish-web-app>
和我的web.xml一样:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/inicio.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>sunny</param-value>
</context-param>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app>
我需要什么才能让它工作?我缺少什么?,除了将路径放在glassfish-web.xml中还有什么可做的吗?
答案 0 :(得分:3)
由于这篇文章我终于解决了它:http://www.marceble.com/2009/07/virtual-directories-in-glassfish/
所以,恢复,
如果您没有glassfish-web.xml
,可以通过菜单File&gt;自行创建<?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 error-url="">
<parameter-encoding default-charset="UTF-8" />
<!-- Here is the problem, you should have your path of "dir" to the
containing folder you wish to share, so in "from" you set the name of the
folder and that is all, you should be able to access to the contents of
the folder -->
<property name="alternatedocroot_1" value="from=/media/* dir=D:\" />
<!-- in this case, the contaning folder is D:\ and the folder to share is
"media" so the requests to "localhost:8080/MyApplication/media/" should
redirect to D:\media\ -->
</glassfish-web-app>
。新文件&gt; Glassfish&gt; Glassfish Descriptor。
你的xml应该是这样的:
{{1}}
答案 1 :(得分:3)
我花了好几个小时来解决这个问题,但终于找到了我的错误。
指出 非常 ,“来自= / yourFolder / *”必须在“dir = / yourDocRoot /”下方以相同名称存在“文件夹。
表示: 如果你的链接应该是“http://yourdomain.com/template/ ...”,那么你的from将是“from = / template / *”,所以你的“dir = / yourDocRoot /”里面必须有一个名为“template”的文件夹”
请勿将此“模板”文件夹输入“dir = ...”
答案 2 :(得分:0)
我有同样的问题, 我正在添加
<property name="alternatedocroot_1" value="from=/uploads/* dir=/Users/osama/Files/"/>
&#13;
内部标签,这是完全错误的。