浏览 1202 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2007-01-24 关键字: 中文 乱码 mongrel
这两天在linux下把oracle, rails,并且也能生成一个脚手架了,可奇怪的是,在linux下生成的脚手架始终无法显示中文,而在windows下的rails生成的脚手架却能正常显示中文,这说明问题应该不是出现在oracle这,想来想出,问题可能是WEBrick的原因, 于是,换装Mongrel,但乱码问题依旧存在(Mongrel在windows上没有试验过),再查看rdoc里的关于DirHandler一节内容(mongrel/handlers.rb),里面提到默认的MIME类型是"text/plain; charset=ISO-8859-1"(原文内容:The default content type is "text/plain; charset=ISO-8859-1" but you can change it anything you want using the DirHandler.default_content_type attribute.),根据他的意思,可以将DirHandler.default_content_type这个属性换成其他的字符集编码,那请教各位高人,这个default_content_type该如何设置呀?
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2007-01-25
刚才又单独试了一个WEBrick的脚本:
require 'webrick' include WEBrick #a function stub to start WEBrick def start_WEBrick(config = {}) config.update(:Port => 3000) server = HTTPServer.new(config) yield server if block_given? ['INT', 'TERM'].each do |signal| trap(signal) { server.shutdown } end server.start end class HelloServlet < HTTPServlet::AbstractServlet def do_GET(req, res) res["content-type"] = "text/html; charset=UTF-8" res.body = %{ <html> <body> 天才 </body> </html> } end alias do_POST do_GET end # start_WEBrick do |server| #servlet "/hello" server.mount("/hello", HelloServlet) end 这样的脚本就能正常显示中文了,那同理,Mongrel中的default_content_type的设置也应该在类似的文件编写一下就行,因为我现在已经安装了Mongrel,使用ruby script/server将会自动调用Mongrel,顺着这条道走下去,应该能找到default_content_type |
|
| 返回顶楼 | |
|
最后更新时间:2007-01-26
解决了...原来用export加个NLS_LANG就行了
|
|
| 返回顶楼 | |


