注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

流星永恒的博客

JSF,Facelets,Rich(Prime)Faces,和java的笔记

 
 
 

日志

 
 

GlassFish3 and PrimeFaces Configuration(上传乱码和comet异步)  

2010-11-06 22:37:54|  分类: jsf2.0 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

1.  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>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>SESSION_EXPIRED_PAGE</param-name>
        <param-value>sessionExpired.html</param-value>
    </context-param>
    <context-param>
        <param-name>org.primefaces.component.captcha.PRIVATE_KEY</param-name>
        <param-value>mykey</param-value>
    </context-param>
    <context-param>
        <param-name>primefaces.SKIN</param-name>
        <param-value>none</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>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>Comet Servlet</servlet-name>
        <servlet-class>org.primefaces.comet.PrimeFacesCometServlet</servlet-class>
        <async-supported>true</async-supported>  <!--异步需要用到,primefaces用的是Atmosphere-->
        <!--//############NOTE HERE!############//-->
    </servlet>
    <servlet-mapping>
        <servlet-name>Comet Servlet</servlet-name>
        <url-pattern>/primefaces_comet/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>1</session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsf</welcome-file>
    </welcome-file-list>
    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/sessionExpired.html</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/404.htm</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/500.html</location>
    </error-page>
</web-app>


2.  sun-web.xml

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app error-url="">
    <context-root>/WebApp</context-root>
    <property name="alternatedocroot_1" value="from=/default/* dir=d:/Media"/>
    <class-loader delegate="true"/>
    <jsp-config>
        <property name="keepgenerated" value="true">
            <description>Keep a copy of the generated servlet class' java code.</description>
        </property>
    </jsp-config>
       <locale-charset-info default-locale="en"><!--如果用到Filter来编码的话,会与Atmospere--comet的异步相冲突,在这里设置可以避免-->
        <locale-charset-map charset="UTF-8" locale="zh"/>
        <parameter-encoding default-charset="UTF-8"/>
    </locale-charset-info>

</sun-web-app>

上传的时候中文就会出现乱码,所以必须要进行编码,如果用Filter的话会与Atmospere-comet异步冲突,在sun-web.xml里面设置的话不会出现冲突。

  评论这张
 
阅读(1450)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018