2013-04-01 53 views
1

我试图让我的页面资源和上传的文件从工作文件夹(使用JSF 2和Netbeans IDE 7.2),所以我不知道如何访问他们,所以我开始阅读如何做到这一点我已经找到了“alternatedocroot”...我一直试图让它创建glassfish-web文件(因为它没有创建),并将属性留下我的glassfish-web.xml像这样:如何使glassfish 3.1.2的alternatedocroot工作?

<?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

我试图访问这样的资源: 的http://本地主机:8080/Plataforma_RAQ战/图片/multifaces.dae (multifaces.dae是3D文件夹内的文件) – Pigritia

+0

或者如果有另一种方式,它也会非常有用 – Pigritia

回答

3

我终于解决了它得益于这个帖子:http://www.marceble.com/2009/07/virtual-directories-in-glassfish/

因此,恢复

  1. ,如果你不具备glassfish-web.xml你可以自己通过菜单文件创建>新建文件> Glassfish> Glassfish描述符。

  2. 你的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=""> 
        <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> 
    
3

我的工作时间来解决这个问题,但终于找到了我的错误。

它指出非常重要的是,“从=/yourFolder/*”与下面的“DIR =/yourDocRoot /”文件夹下的同名存在。

方式: 如果你的链接应该是“http://yourdomain.com/template/ ...”,那么你的将是“从= /模板/ *”,让你的“DIR =/yourDocRoot /”必须有一个文件夹内与名称“模板”。

不要进入这个“模板”文件夹到你“DIR = ...”

相关问题