1

ページのリソースとアップロードされたファイルをプロジェクトの作業フォルダー (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 Descriptor] メニューから自分で作成できます。

  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 に答える