1

我正在尝试从 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 中还有什么要做的吗?

4

3 回答 3

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>
    
于 2013-04-03T05:03:59.303 回答
3

我工作了几个小时来解决这个问题,但最终发现了我的错误。

需要指出的是,“From=/yourFolder/*”必须以相同的名称存在于“dir=/yourDocRoot/”文件夹下。

意思是:如果你的链接应该是“ http://yourdomain.com/template/ ...”,那么你的来自将是“from=/template/*”,所以你的“dir=/yourDocRoot/”必须有一个文件夹里面的名称为“模板”。

不要将此“模板”文件夹输入到您的“dir=...”中

于 2013-06-27T21:12:05.503 回答
0

我有同样的问题,我正在添加

<property name="alternatedocroot_1" value="from=/uploads/* dir=/Users/osama/Files/"/>

内部标签,这是完全不正确的。

于 2018-06-01T13:33:46.023 回答