- 浏览: 1225579 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (353)
- java基础 (40)
- tapestry (16)
- gwt (14)
- ajax (7)
- linux (8)
- ubuntu (18)
- eclipse (6)
- dojo (2)
- javascript (7)
- maven (4)
- 日常生活 (29)
- web2.0 (2)
- jsonrpc (1)
- compass (1)
- lucene (0)
- spring (10)
- cluster (3)
- 数据结构 (2)
- sqlserver (1)
- tomcat (2)
- swing (1)
- servlet (1)
- hibernate (1)
- firefox (1)
- Java-Puzzlers (1)
- Wicket (2)
- mysql (10)
- windows (5)
- Webwork (1)
- struts2 (1)
- Seam (2)
- jboss (1)
- idea (6)
- 分布计算 (3)
- Python-Django (7)
- Hadoop (1)
- 工具 (3)
- Tokyo Tyrant (2)
- Comet (1)
- android (115)
- 音乐 (6)
- cxf (1)
- mqtt (1)
最新评论
-
hesai_vip:
学习了,感谢
gradlew wrapper使用下载到本地的gradle.zip文件安装。 -
imknown:
姚瑶大坏蛋 写道我也遇到了这个,用你这个方法,导致下拉刷新不起 ...
解决android-Ultra-Pull-To-Refresh下拉刷新组件中嵌套ViewPager的一个bug -
姚瑶大坏蛋:
我也遇到了这个,用你这个方法,导致下拉刷新不起作用了,你遇到过 ...
解决android-Ultra-Pull-To-Refresh下拉刷新组件中嵌套ViewPager的一个bug -
寐语者:
LeaderElection(String zookeeper ...
使用Zookeeper来为你的程序加上Leader Election的功能。 -
fyc0109:
博主, 安装了一部分还是报这个错误!FAILURE: Buil ...
gradlew wrapper使用下载到本地的gradle.zip文件安装。
现在正在使用T5开发一个小项目。 因为现在T5还正处于发展中。 而且没有像T4一样有许多的文档。 和例子(Workbench, Vlib)。 所以我会把在这个开发中遇到的一些问题记录下来。
tapestry5.0.5现在默认支持UTF-8编码。 但是发现在form提交数据后。 数据变成了乱码。
解决方案是增加一个Filter。
然后contribute给RequestHandler。
以上代码都是放在AppModule.java中。。
参考:http://wiki.apache.org/tapestry/Tapestry5Utf8Encoding
如果是get方式提交,应该设置server.xml中RUIEncoding="UTF-8"
都清除了,也换成了jetty5.1.14. 问题依旧,绝望了:(
很有可能你的mysql数据库不是用的utf-8.
你可以调试下 在你onSuccess里面看看 提交后的java class的数据是不是乱码。
都清除了,也换成了jetty5.1.14. 问题依旧,绝望了:(
.java, .html采用UTF-8
数据库utf-8
环境: WindowsXP + mysql5.0.18 + jetty5.1.12
乱码依旧:(
jetty5.1.14. mysql5. 在ubuntu 和windows xp下就没问题。。 呵呵 RP有问题。
.java, .html采用UTF-8
数据库utf-8
环境: WindowsXP + mysql5.0.18 + jetty5.1.12
乱码依旧:(
tapestry5.0.5现在默认支持UTF-8编码。 但是发现在form提交数据后。 数据变成了乱码。
解决方案是增加一个Filter。
public RequestFilter buildUtf8Filter( @InjectService("RequestGlobals") final RequestGlobals requestGlobals) { return new RequestFilter() { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { requestGlobals.getHTTPServletRequest().setCharacterEncoding("UTF-8"); return handler.service(request, response); } }; }
然后contribute给RequestHandler。
public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, @InjectService("TimingFilter") final RequestFilter timingFilter, @InjectService("Utf8Filter") final RequestFilter utf8Filter) { configuration.add("Utf8Filter", utf8Filter); // handle UTF-8 configuration.add("Timing", timingFilter); }
以上代码都是放在AppModule.java中。。
参考:http://wiki.apache.org/tapestry/Tapestry5Utf8Encoding
评论
29 楼
dengyin2000
2007-12-28
谁会用get去穿中文内容。 一般get都是用来传ID的。
28 楼
liyong_2003_cn
2007-12-28
iorigod123 写道
小弟也碰到过这种问题,有upload组件就会提交成乱码,小弟的解决方法有点笨,就是搞个转换,居然可以成功转换,代码如下:
public static String getUTF8(String temp){
try{
return new String(temp.getBytes("iso-8859-1"),"utf-8");
}catch(Exception e){
return "";
}
}
象这种转换是最保险的,用filter的情况,对post提交是有效的,但是对get提交是无效的,这个跟post和get提交的机制有关系。以前项目遇到过这个问题,现在基本上都采用转换了,不用filter了,效率没仔细比较过,估计差不太多。
public static String getUTF8(String temp){
try{
return new String(temp.getBytes("iso-8859-1"),"utf-8");
}catch(Exception e){
return "";
}
}
如果是get方式提交,应该设置server.xml中RUIEncoding="UTF-8"
27 楼
iorigod123
2007-12-28
小弟也碰到过这种问题,有upload组件就会提交成乱码,小弟的解决方法有点笨,就是搞个转换,居然可以成功转换,代码如下:
public static String getUTF8(String temp){
try{
return new String(temp.getBytes("iso-8859-1"),"utf-8");
}catch(Exception e){
return "";
}
}
public static String getUTF8(String temp){
try{
return new String(temp.getBytes("iso-8859-1"),"utf-8");
}catch(Exception e){
return "";
}
}
26 楼
kris_xu
2007-09-05
如果是get方式提交,应该设置server.xml中RUIEncoding="UTF-8"
25 楼
kris_xu
2007-09-05
和form的提交方式有关吗?get?post?
24 楼
xo_tobacoo
2007-09-05
要解决乱码,首先要了解你的环境中那些位置涉及字符编码:
jsp页面要设置
开发工具要设置
连接数据库要设置
java包
最好的办法是使用楼主使用的方案,过滤器
在tomcat的示例里有个过滤器,拷贝过去,改下就可以了
jsp页面要设置
开发工具要设置
连接数据库要设置
java包
最好的办法是使用楼主使用的方案,过滤器
在tomcat的示例里有个过滤器,拷贝过去,改下就可以了
23 楼
match927
2007-09-05
这个文件AppModule.java在那里?谢谢
22 楼
javersion
2007-08-28
你的表单提交方式是用的post还是get,如果是get,就会发生乱码!
21 楼
koda
2007-08-28
先在maillist上散一下:)
20 楼
Linuxboy
2007-08-28
将这个问题提交到jira吧
19 楼
koda
2007-08-28
我终于找到了问题发生的原因了!!!但是没有解决方案
真正的问题是:如果form里包含有上传文件的field,则其他textfield提交的中文乱码;或者,如果显式地在<form>标签中加入属性 enctype="multipart/form-data"则提交的textfield中文值乱码。
真正的问题是:如果form里包含有上传文件的field,则其他textfield提交的中文乱码;或者,如果显式地在<form>标签中加入属性 enctype="multipart/form-data"则提交的textfield中文值乱码。
18 楼
dengyin2000
2007-08-24
我贴下我的吧。。 跟你的也差不多。。<br/>
<br/>
<br/>
<div class='code_title'>java 代码</div>
<div class='dp-highlighter'>
<div class='bar'> </div>
<ol class='dp-j' start='1'>
<li class='alt'><span><span class='keyword'>package</span><span> com.javaeye.dengyin2000.gtts.services; </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span><span class='keyword'>import</span><span> java.io.IOException; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> java.math.BigDecimal; </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.commons.logging.Log; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.Translator; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.MappedConfiguration; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.OrderedConfiguration; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.ServiceBinder; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.annotations.InjectService; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.services.Request; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.services.RequestFilter; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.services.RequestGlobals; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.services.RequestHandler; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.services.Response; </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span><span class='keyword'>import</span><span> com.javaeye.dengyin2000.gtts.tapestry.BigDecimalTranslator; </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span><span class='comment'>/**</span> </span></li>
<li class='alt'><span><span class='comment'> * This module is automatically included as part of the Tapestry IoC Registry, it's a good place to</span> </span></li>
<li class=''><span><span class='comment'> * configure and extend Tapestry, or to place your own service definitions.</span> </span></li>
<li class='alt'><span><span class='comment'> */</span><span> </span></span></li>
<li class=''><span><span class='keyword'>public</span><span> </span><span class='keyword'>class</span><span> AppModule </span></span></li>
<li class='alt'><span>{ </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> bind(ServiceBinder binder) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='comment'>// binder.bind(MyServiceInterface.class, MyServiceImpl.class);</span><span> </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='comment'>// Make bind() calls on the binder object to define most IoC services.</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// Use service builder methods (example below) when the implementation</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// is provided inline, or requires more initialization than simply</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// invoking the constructor. </span><span> </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> contributeApplicationDefaults( </span></span></li>
<li class=''><span> MappedConfiguration<String, String> configuration) </span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='comment'>// Contributions to ApplicationDefaults will override any contributions to</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// FactoryDefaults (with the same key). Here we're restricting the supported</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// locales to just "en" (English). As you add localised message catalogs and other assets,</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// you can extend this list of locales (it's a comma seperated series of locale names;</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// the first locale name is the default when there's no reasonable match).</span><span> </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span> configuration.add(<span class='string'>"tapestry.supported-locales"</span><span>, </span><span class='string'>"en"</span><span>); </span></span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='comment'>/**</span> </span></li>
<li class='alt'><span><span class='comment'> * This is a service definition, the service will be named "TimingFilter". The interface,</span> </span></li>
<li class=''><span><span class='comment'> * RequestFilter, is used within the RequestHandler service pipeline, which is built from the</span> </span></li>
<li class='alt'><span><span class='comment'> * RequestHandler service configuration. Tapestry IoC is responsible for passing in an</span> </span></li>
<li class=''><span><span class='comment'> * appropriate Log instance. Requests for static resources are handled at a higher level, so</span> </span></li>
<li class='alt'><span><span class='comment'> * this filter will only be invoked for Tapestry related requests.</span> </span></li>
<li class=''><span><span class='comment'> * </span> </span></li>
<li class='alt'><span><span class='comment'> * <p></span> </span></li>
<li class=''><span><span class='comment'> * Service builder methods are useful when the implementation is inline as an inner class</span> </span></li>
<li class='alt'><span><span class='comment'> * (as here) or require some other kind of special initialization. In most cases,</span> </span></li>
<li class=''><span><span class='comment'> * use the static bind() method instead. </span> </span></li>
<li class='alt'><span><span class='comment'> * </span> </span></li>
<li class=''><span><span class='comment'> * <p></span> </span></li>
<li class='alt'><span><span class='comment'> * If this method was named "build", then the service id would be taken from the </span> </span></li>
<li class=''><span><span class='comment'> * service interface and would be "RequestFilter". Since Tapestry already defines</span> </span></li>
<li class='alt'><span><span class='comment'> * a service named "RequestFilter" we use an explicit service id that we can reference</span> </span></li>
<li class=''><span><span class='comment'> * inside the contribution method.</span> </span></li>
<li class='alt'><span><span class='comment'> */</span><span> </span></span></li>
<li class=''><span> <span class='keyword'>public</span><span> RequestFilter buildTimingFilter(</span><span class='keyword'>final</span><span> Log log) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>return</span><span> </span><span class='keyword'>new</span><span> RequestFilter() </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>boolean</span><span> service(Request request, Response response, RequestHandler handler) </span></span></li>
<li class='alt'><span> <span class='keyword'>throws</span><span> IOException </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> <span class='keyword'>long</span><span> startTime = System.currentTimeMillis(); </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>try</span><span> </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> <span class='comment'>// The reponsibility of a filter is to invoke the corresponding method</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// in the handler. When you chain multiple filters together, each filter</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// received a handler that is a bridge to the next filter.</span><span> </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>return</span><span> handler.service(request, response); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> <span class='keyword'>finally</span><span> </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> <span class='keyword'>long</span><span> elapsed = System.currentTimeMillis() - startTime; </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span> log.info(String.format(<span class='string'>"Request time: %d ms"</span><span>, elapsed)); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> }; </span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>public</span><span> RequestFilter buildUtf8Filter( </span></span></li>
<li class=''><span> <span class='annotation'>@InjectService</span><span>(</span><span class='string'>"RequestGlobals"</span><span>) </span><span class='keyword'>final</span><span> RequestGlobals requestGlobals) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>return</span><span> </span><span class='keyword'>new</span><span> RequestFilter() </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>boolean</span><span> service(Request request, Response response, RequestHandler handler) </span></span></li>
<li class='alt'><span> <span class='keyword'>throws</span><span> IOException </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> requestGlobals.getHTTPServletRequest().setCharacterEncoding(<span class='string'>"UTF-8"</span><span>); </span></span></li>
<li class=''><span> <span class='keyword'>return</span><span> handler.service(request, response); </span></span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> }; </span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='comment'>/**</span> </span></li>
<li class=''><span><span class='comment'> * This is a contribution to the RequestHandler service configuration. This is how we extend</span> </span></li>
<li class='alt'><span><span class='comment'> * Tapestry using the timing filter. A common use for this kind of filter is transaction</span> </span></li>
<li class=''><span><span class='comment'> * management or security.</span> </span></li>
<li class='alt'><span><span class='comment'> */</span><span> </span></span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>void</span><span> contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, </span></span></li>
<li class='alt'><span> <span class='annotation'>@InjectService</span><span>(</span><span class='string'>"TimingFilter"</span><span>) </span></span></li>
<li class=''><span> RequestFilter filter, <span class='annotation'>@InjectService</span><span>(</span><span class='string'>"Utf8Filter"</span><span>) RequestFilter utf8Filter) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='comment'>// Each contribution to an ordered configuration has a name, When necessary, you may</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// set constraints to precisely control the invocation order of the contributed filter</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// within the pipeline.</span><span> </span></span></li>
<li class='alt'><span> configuration.add(<span class='string'>"Utf8Filter"</span><span>, utf8Filter); </span></span></li>
<li class=''><span> configuration.add(<span class='string'>"Timing"</span><span>, filter); </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> contributeTranslatorDefaultSource( </span></span></li>
<li class='alt'><span> MappedConfiguration<Class, Translator> configuration) </span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> configuration.add(BigDecimal.<span class='keyword'>class</span><span>, </span><span class='keyword'>new</span><span> BigDecimalTranslator()); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> contributeTranslatorSource( </span></span></li>
<li class='alt'><span> MappedConfiguration<String, Translator> configuration) </span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> configuration.add(<span class='string'>"bigdecimal"</span><span>, </span><span class='keyword'>new</span><span> BigDecimalTranslator()); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span>} </span></li>
</ol>
</div>
<br/>
<br/>
<div class='code_title'>java 代码</div>
<div class='dp-highlighter'>
<div class='bar'> </div>
<ol class='dp-j' start='1'>
<li class='alt'><span><span class='keyword'>package</span><span> com.javaeye.dengyin2000.gtts.services; </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span><span class='keyword'>import</span><span> java.io.IOException; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> java.math.BigDecimal; </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.commons.logging.Log; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.Translator; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.MappedConfiguration; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.OrderedConfiguration; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.ServiceBinder; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.ioc.annotations.InjectService; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.services.Request; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.services.RequestFilter; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.services.RequestGlobals; </span></span></li>
<li class='alt'><span><span class='keyword'>import</span><span> org.apache.tapestry.services.RequestHandler; </span></span></li>
<li class=''><span><span class='keyword'>import</span><span> org.apache.tapestry.services.Response; </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span><span class='keyword'>import</span><span> com.javaeye.dengyin2000.gtts.tapestry.BigDecimalTranslator; </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span><span class='comment'>/**</span> </span></li>
<li class='alt'><span><span class='comment'> * This module is automatically included as part of the Tapestry IoC Registry, it's a good place to</span> </span></li>
<li class=''><span><span class='comment'> * configure and extend Tapestry, or to place your own service definitions.</span> </span></li>
<li class='alt'><span><span class='comment'> */</span><span> </span></span></li>
<li class=''><span><span class='keyword'>public</span><span> </span><span class='keyword'>class</span><span> AppModule </span></span></li>
<li class='alt'><span>{ </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> bind(ServiceBinder binder) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='comment'>// binder.bind(MyServiceInterface.class, MyServiceImpl.class);</span><span> </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='comment'>// Make bind() calls on the binder object to define most IoC services.</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// Use service builder methods (example below) when the implementation</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// is provided inline, or requires more initialization than simply</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// invoking the constructor. </span><span> </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> contributeApplicationDefaults( </span></span></li>
<li class=''><span> MappedConfiguration<String, String> configuration) </span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='comment'>// Contributions to ApplicationDefaults will override any contributions to</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// FactoryDefaults (with the same key). Here we're restricting the supported</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// locales to just "en" (English). As you add localised message catalogs and other assets,</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// you can extend this list of locales (it's a comma seperated series of locale names;</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// the first locale name is the default when there's no reasonable match).</span><span> </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span> configuration.add(<span class='string'>"tapestry.supported-locales"</span><span>, </span><span class='string'>"en"</span><span>); </span></span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='comment'>/**</span> </span></li>
<li class='alt'><span><span class='comment'> * This is a service definition, the service will be named "TimingFilter". The interface,</span> </span></li>
<li class=''><span><span class='comment'> * RequestFilter, is used within the RequestHandler service pipeline, which is built from the</span> </span></li>
<li class='alt'><span><span class='comment'> * RequestHandler service configuration. Tapestry IoC is responsible for passing in an</span> </span></li>
<li class=''><span><span class='comment'> * appropriate Log instance. Requests for static resources are handled at a higher level, so</span> </span></li>
<li class='alt'><span><span class='comment'> * this filter will only be invoked for Tapestry related requests.</span> </span></li>
<li class=''><span><span class='comment'> * </span> </span></li>
<li class='alt'><span><span class='comment'> * <p></span> </span></li>
<li class=''><span><span class='comment'> * Service builder methods are useful when the implementation is inline as an inner class</span> </span></li>
<li class='alt'><span><span class='comment'> * (as here) or require some other kind of special initialization. In most cases,</span> </span></li>
<li class=''><span><span class='comment'> * use the static bind() method instead. </span> </span></li>
<li class='alt'><span><span class='comment'> * </span> </span></li>
<li class=''><span><span class='comment'> * <p></span> </span></li>
<li class='alt'><span><span class='comment'> * If this method was named "build", then the service id would be taken from the </span> </span></li>
<li class=''><span><span class='comment'> * service interface and would be "RequestFilter". Since Tapestry already defines</span> </span></li>
<li class='alt'><span><span class='comment'> * a service named "RequestFilter" we use an explicit service id that we can reference</span> </span></li>
<li class=''><span><span class='comment'> * inside the contribution method.</span> </span></li>
<li class='alt'><span><span class='comment'> */</span><span> </span></span></li>
<li class=''><span> <span class='keyword'>public</span><span> RequestFilter buildTimingFilter(</span><span class='keyword'>final</span><span> Log log) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>return</span><span> </span><span class='keyword'>new</span><span> RequestFilter() </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>boolean</span><span> service(Request request, Response response, RequestHandler handler) </span></span></li>
<li class='alt'><span> <span class='keyword'>throws</span><span> IOException </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> <span class='keyword'>long</span><span> startTime = System.currentTimeMillis(); </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>try</span><span> </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> <span class='comment'>// The reponsibility of a filter is to invoke the corresponding method</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// in the handler. When you chain multiple filters together, each filter</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// received a handler that is a bridge to the next filter.</span><span> </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>return</span><span> handler.service(request, response); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> <span class='keyword'>finally</span><span> </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> <span class='keyword'>long</span><span> elapsed = System.currentTimeMillis() - startTime; </span></span></li>
<li class=''><span> </span></li>
<li class='alt'><span> log.info(String.format(<span class='string'>"Request time: %d ms"</span><span>, elapsed)); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> }; </span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='keyword'>public</span><span> RequestFilter buildUtf8Filter( </span></span></li>
<li class=''><span> <span class='annotation'>@InjectService</span><span>(</span><span class='string'>"RequestGlobals"</span><span>) </span><span class='keyword'>final</span><span> RequestGlobals requestGlobals) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>return</span><span> </span><span class='keyword'>new</span><span> RequestFilter() </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>boolean</span><span> service(Request request, Response response, RequestHandler handler) </span></span></li>
<li class='alt'><span> <span class='keyword'>throws</span><span> IOException </span></span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> requestGlobals.getHTTPServletRequest().setCharacterEncoding(<span class='string'>"UTF-8"</span><span>); </span></span></li>
<li class=''><span> <span class='keyword'>return</span><span> handler.service(request, response); </span></span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> }; </span></li>
<li class='alt'><span> } </span></li>
<li class=''><span> </span></li>
<li class='alt'><span> <span class='comment'>/**</span> </span></li>
<li class=''><span><span class='comment'> * This is a contribution to the RequestHandler service configuration. This is how we extend</span> </span></li>
<li class='alt'><span><span class='comment'> * Tapestry using the timing filter. A common use for this kind of filter is transaction</span> </span></li>
<li class=''><span><span class='comment'> * management or security.</span> </span></li>
<li class='alt'><span><span class='comment'> */</span><span> </span></span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>void</span><span> contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, </span></span></li>
<li class='alt'><span> <span class='annotation'>@InjectService</span><span>(</span><span class='string'>"TimingFilter"</span><span>) </span></span></li>
<li class=''><span> RequestFilter filter, <span class='annotation'>@InjectService</span><span>(</span><span class='string'>"Utf8Filter"</span><span>) RequestFilter utf8Filter) </span></span></li>
<li class='alt'><span> { </span></li>
<li class=''><span> <span class='comment'>// Each contribution to an ordered configuration has a name, When necessary, you may</span><span> </span></span></li>
<li class='alt'><span> <span class='comment'>// set constraints to precisely control the invocation order of the contributed filter</span><span> </span></span></li>
<li class=''><span> <span class='comment'>// within the pipeline.</span><span> </span></span></li>
<li class='alt'><span> configuration.add(<span class='string'>"Utf8Filter"</span><span>, utf8Filter); </span></span></li>
<li class=''><span> configuration.add(<span class='string'>"Timing"</span><span>, filter); </span></span></li>
<li class='alt'><span> </span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> contributeTranslatorDefaultSource( </span></span></li>
<li class='alt'><span> MappedConfiguration<Class, Translator> configuration) </span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> configuration.add(BigDecimal.<span class='keyword'>class</span><span>, </span><span class='keyword'>new</span><span> BigDecimalTranslator()); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span> </span></li>
<li class=''><span> <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>void</span><span> contributeTranslatorSource( </span></span></li>
<li class='alt'><span> MappedConfiguration<String, Translator> configuration) </span></li>
<li class=''><span> { </span></li>
<li class='alt'><span> configuration.add(<span class='string'>"bigdecimal"</span><span>, </span><span class='keyword'>new</span><span> BigDecimalTranslator()); </span></span></li>
<li class=''><span> } </span></li>
<li class='alt'><span>} </span></li>
</ol>
</div>
17 楼
koda
2007-08-23
代码也贴出来
package org.opend.bogo.services; public class AppModule { public void contributeRequestHandler( OrderedConfiguration<RequestFilter> configuration, @InjectService("TimingFilter") final RequestFilter timingFilter, @InjectService("Utf8Filter") final RequestFilter utf8Filter) { configuration.add("Utf8Filter", utf8Filter); // handle UTF-8 } public RequestFilter buildUtf8Filter( @InjectService("RequestGlobals") final RequestGlobals requestGlobals) { return new RequestFilter() { public boolean service(Request request, Response response, RequestHandler handler) throws IOException { requestGlobals.getHTTPServletRequest().setCharacterEncoding("utf-8"); return handler.service(request, response); } }; } }
16 楼
koda
2007-08-23
我在onSuccess里面插入数据库之前打印就是乱码
另外我创建数据库的时候用下面的语句
CREATE DATABASE bogo CHARACTER SET UTF8 COLLATE utf8_general_ci;
另外我创建数据库的时候用下面的语句
CREATE DATABASE bogo CHARACTER SET UTF8 COLLATE utf8_general_ci;
15 楼
dengyin2000
2007-08-23
koda 写道
引用
要记得清除开发环境和浏览器的缓存。
都清除了,也换成了jetty5.1.14. 问题依旧,绝望了:(
很有可能你的mysql数据库不是用的utf-8.
你可以调试下 在你onSuccess里面看看 提交后的java class的数据是不是乱码。
14 楼
Linuxboy
2007-08-23
那就奇怪了。我的开发环境是:XPsp2+mysql5(utf8)+eclipse3.3+jetty6.1.3+tapestry5.0.5
在form中输入中文提交后,中文显示正常。
在form中输入中文提交后,中文显示正常。
13 楼
koda
2007-08-23
引用
要记得清除开发环境和浏览器的缓存。
都清除了,也换成了jetty5.1.14. 问题依旧,绝望了:(
12 楼
Linuxboy
2007-08-22
要记得清除开发环境和浏览器的缓存。
11 楼
dengyin2000
2007-08-22
koda 写道
引用
确定你的html 和 java 文件的编码用的是utf-8? eclipse的话 在文件上右键 ---》 然后properties。
.java, .html采用UTF-8
数据库utf-8
环境: WindowsXP + mysql5.0.18 + jetty5.1.12
乱码依旧:(
jetty5.1.14. mysql5. 在ubuntu 和windows xp下就没问题。。 呵呵 RP有问题。
10 楼
koda
2007-08-22
引用
确定你的html 和 java 文件的编码用的是utf-8? eclipse的话 在文件上右键 ---》 然后properties。
.java, .html采用UTF-8
数据库utf-8
环境: WindowsXP + mysql5.0.18 + jetty5.1.12
乱码依旧:(
发表评论
-
解决用run-jetty-run锁住css,js文件的问题。
2008-09-25 17:46 6650开发中用run-jetty-run插件启动jetty调式tap ... -
打造Tapestry5中的智能的错误页面。
2008-09-18 15:59 1812我们一般需要为生产和开发环境准备两套error page。 t ... -
T5这么多的Page Lifecycle method, 应该怎样使用?
2008-09-04 18:18 2398Tapestry5种大概有以下Page ... -
扔掉T5复杂的Grid组件,打造自己灵活的支持分页排序组件。
2008-01-03 13:12 2876Grid算是比较T5中较复杂的一个组件,我也有篇介绍Grid怎 ... -
对Tapestry的一点思考。
2007-12-27 23:33 4097Tapestry5已经开发了蛮久了。 听说最近要发布T5.0. ... -
Tapestry 5.0.5 bug, TAPESTRY-1648
2007-08-26 12:20 2633有一个domian object, 其中有个property的 ... -
T5 技巧 3:使用“t::body”进行布局。
2007-08-25 00:08 2943现在正在使用T5开发一个小项目。 因为现在T5还正处于发展中。 ... -
T5 技巧 2:为Grid组件的每一行增加“删除/修改”链接。
2007-08-21 12:35 9038现在正在使用T5开发一个小项目。 因为现在T5还正处于发展中。 ... -
T5 developing with WTP and TOMCAT
2007-08-16 09:50 2746以下是我发给tapestry右键列表的问题。 现在还没有人回复 ... -
Wicket Vs Tapestry
2007-05-11 14:41 7487我是一个tapestry的老用户。从学校毕业就开始使用tape ... -
Tapestry5中 page template不能reload。
2007-05-09 13:50 5890上午看了下tapestry5的文档,然后自己写了个简单的页面。 ... -
Tapestry Table 组件的强大(分页查询时只fetch当前页的数据)。
2006-03-01 16:00 4369导入的blog格式乱了,大 ... -
Tapestry 显示图片
2006-03-06 16:00 2781导入的blog格式乱了,请看我的msn spaces blog ... -
@Persist 解释
2006-03-08 16:00 3156a) @Persist("client") ... -
原创 Tapestry的Cache组件
2006-12-22 11:24 5093有许多页面的一部分或者这个页面是很少更新的,他们通常是由外部文 ...
相关推荐
Bart_T5-摘要使用来自Bart和T5模型的汇总任务可以直接比较文本摘要Bart和T5的最佳模型。安装需求pip install -U transformerspip install -U torchpip install flask跑步python app.py巴特总结T5总结
迪文串口屏T5UIC1是一款专用于串行通信显示的设备,适用于各种工业控制、智能家居等领域的用户界面设计。此开发资料压缩包包含了全面的开发资源,旨在帮助开发者快速有效地进行屏幕的编程与应用。以下是基于提供的...
在本应用中,它被用来驱动迪文(Dimen)的T5UIC1液晶显示屏,该屏幕型号为DMT48270C043-04WR,具备显示汉字、英文和数字的能力,同时支持图形化操作如画线和绘制矩形。 迪文T5UIC1屏是迪文科技推出的一款智能显示...
T5基于Transformer架构,这是由Vaswani等人在2017年提出的,它改变了以往的循环神经网络(RNN)和长短时记忆网络(LSTM)在处理长距离依赖时的效率问题。Transformer模型由编码器和解码器两部分组成,使用自注意力...
知识点1:Instruction Tuning是一种训练大语言模型的方式,可以极大地提升大语言模型的理解能力。 知识点2:Prompting方法可以预示着针对大模型的下游微调,将成为研究领域关注的重点。 知识点3:Chain of Thought...
【GNUVario-TTGO-T5-website:GNUVario-TTGO-T5-网站】是一个专注于GNUVario-E项目的在线资源平台,该平台致力于提供基于ESP32芯片的开源硬件设计和变量计的详细信息。这个项目的核心是将开源精神应用于电子工程领域...
T5飞马 中文生成式预训练模型,以mT5为基础架构和初始权重,通过类似PEGASUS的方式进行预训练。 详情可见: ://kexue.fm/archives/8209 分词器 我们将T5 PEGASUS的令牌生成器转换成BERT的令牌生成器,它对中文更友好...
DWIN迪文科技是一家专注于智能显示解决方案的公司,其T5L系列是他们的一款高性价比、低功耗的图形液晶模块。这些模块广泛应用于工业控制、智能家居、仪器仪表、车载设备等各种嵌入式系统中,提供清晰、直观的用户...
通过实际应用案例,展示如何将理论知识应用于实践中,并提供常见问题的解决方案,帮助开发者解决开发过程中的实际问题。 综上所述,《T5L DGUSII 应用开发指南202007101》是一份全面且实用的参考资料,不仅覆盖了...
1. **预处理**:将输入问题和上下文文本转化为模型可理解的格式。 2. **编码**:将预处理后的输入馈送给T5-Small模型,模型将其转换为内部表示。 3. **解码**:模型根据编码的输入生成答案序列。 4. **后处理**:将...
1. **用户手册**:提供详细的技术规格、功能介绍、接口定义等,帮助开发者了解T5L芯片的基本特性及操作方式。 2. **开发板资料**:包括开发板硬件设计图、电路原理图、接线指南等,有助于搭建开发环境和进行硬件...
【T5UIC1工具集】是一套专为IT专业人士设计的综合性软件工具包,它包含了一系列用于UI(用户界面)开发、测试、优化和调试的实用工具。这个压缩包文件名为"T5UIC1工具集(1).zip",意味着它可能是该工具集的一个特定...
6. **调试工具**:Keil C51集成的调试器允许开发者在代码运行时查看和修改变量状态,设置断点,单步执行,有助于快速定位和解决问题。 7. **驱动程序与库**:项目模板通常包含了一些预编译的驱动程序和库函数,比如...
友价T5免签约支付接口插件是一款专为友价T5系统设计的支付解决方案,旨在简化支付流程,无需经过繁琐的签约手续即可接入第三方支付平台。这款插件的亮点在于其灵活性和便捷性,允许用户根据自己的需求自主配置支付...
【T5贴片二极管】是电子元器件中的一种,属于快速开关二极管,其型号为1N4448W。该二极管采用塑封塑料体设计,端子为可焊镀铅,符合MIL-STD-750标准的2026方法,便于自动插入和表面安装。二极管的极性在壳体上有明确...
- **问题回答**:对于问答系统而言,T5模型能够准确理解问题并给出相应的答案。 - **文本分类**:在文本分类任务中,T5模型通过转换为文本到文本的问题,能够识别出文本所属的类别。 - **机器翻译**:在机器翻译领域...
1. **DGUS2系统**:DGUS(迪文通用智能系统)是DWIN公司推出的一种嵌入式图形用户界面解决方案,DGUS2是其第二代产品,具有强大的图形处理能力和丰富的应用程序接口(API),能够快速构建复杂的交互式用户界面。...