我如何使glassfish 3.1.2的alternatedocroot工作? [英] How do I make alternatedocroot work in glassfish 3.1.2?

查看:104
本文介绍了我如何使glassfish 3.1.2的alternatedocroot工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的页面资源和上传的文件从工作文件夹(使用JSF 2和Netbeans IDE 7.2)中移出,因此我不知道如何访问它们,所以我开始阅读如何操作它和我已经找到了alternatedocroot...我一直在试图让它创建glassfish-web文件(因为它没有创建),并将属性留下我的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 error-url =>
< / glassfish-web-app>

和我的web.xml是这样的:



< pre class =lang-xml prettyprint-override> <?xml version =1.0encoding =UTF-8?>
< web-app version =3.0xmlns =http://java.sun.com/xml/ns/javaeexmlns:xsi =http://www.w3.org/2001/ XMLSchema-instancexsi: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>
<参数值>开发< /参数值>
< / context-param>
< servlet>
< servlet-name> Faces Servlet< / servlet-name>
< servlet-class> javax.faces.webapp.FacesServlet< / servlet-class>
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>
<参数值>晴< /参数值>
< / context-param>

< filter>
< filter-name> PrimeFaces FileUpload过滤器< /过滤器名称>
< filter-class> org.primefaces.webapp.filter.FileUploadFilter< / filter-class>
< / filter>

< filter-mapping>
< filter-name> PrimeFaces FileUpload过滤器< /过滤器名称>
< servlet-name> Faces Servlet< / servlet-name>
< / filter-mapping>


< / web-app>

我还需要什么才能让它工作?,我错过了什么?要把路径放在glassfish-web.xml中吗?

解决方案

我最终解决了这个问题,感谢这篇文章: http://www.marceble.com/2009/07/virtual-directories- in-glassfish /



因此,恢复,


  1. <如果你没有 glassfish-web.xml ,你可以通过菜单File> New File> Glassfish> Glassfish Descriptor来创建它。

    / li>

  2. 您的xml应该是这样的:

     <?xml version =1.0encoding =UTF-8?> 
    <!DOCTYPE glassfish-web-app PUBLIC
    - // GlassFish.org //DTD GlassFish应用服务器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/>
    <! - 这是问题所在,你应该将你的路径设为dir到你想共享的
    包含文件夹,所以在from中设置$ b $的名字b文件夹,即所有,你应该能够访问
    文件夹的内容 - >
    < property name =alternatedocroot_1value =from = / media / * dir = D:\/>
    <! - 在这种情况下,共享文件夹是D:\并且要共享的文件夹是
    media,因此对localhost:8080 / MyApplication / media /的请求应为
    重定向到D:\ media\ - >
    < / glassfish-web-app>



I'm trying to get my page resources and uploaded files out of the proyect working folder (working with JSF 2 and in Netbeans IDE 7.2) so I did not know how to access them, so i started to read how to do it and I have found the "alternatedocroot"... I have been trying to get it work creating the glassfish-web file (because it was not created) and putting the property leaving my glassfish-web.xml like this:

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

and my web.xml like this:

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

what else do i need to get it working ?, what I am missing ?, is there anything more to do than putting the path in the glassfish-web.xml ?

解决方案

I finally solved it thanks to this post: http://www.marceble.com/2009/07/virtual-directories-in-glassfish/

So, resuming,

  1. if you do not have the glassfish-web.xml you can create it by yourself via the menu File > New File > Glassfish > Glassfish Descriptor.

  2. your xml should be like this :

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

这篇关于我如何使glassfish 3.1.2的alternatedocroot工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆