我的Servlet(jdk1.1.7a)不能用中文传参数

PerduBug 2000-09-12 07:51:00
我的Servlet(jdk1.1.7a)

在用GET方法传参数时,不能用中文,我已经URLEncode.encode("str")过了

但POST方法是可以的

请各位大虾指教!!!
...全文
141 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tommy Chang 2000-09-19
  • 打赏
  • 举报
回复
to joy:
那样写法跟你编译方式有关。编译时可以指定编码方式的。

:)

BTW,对于从网页中传来的参数,显示在网页中或写到数据库有时需要两种不同的编码解码方式。试试8859_1,gz2312的排列组合。
即:1。不用转
2。用8859_1去get_byte,用gb2312来new string
3。用gb2312去get_byte,用8859_1来new string

另外要小心一件事,就是以前本人在使用nt4 server+netscape+websphere的时候,居然和nt4 server+apache+websphere情况不同,而且在浏览器中语言设置居然直接影响编码方式的组合。

提起中文问题,真是一言难尽啊!!!
joy 2000-09-19
  • 打赏
  • 举报
回复
hello white,用了你的办法,汉字显示正常,但放入SQL语句还是查不到东西?
我就直接写成SQl = "select * from user where username='刘'"也不行?
SQL语句好像根本不支持中文?
white 2000-09-14
  • 打赏
  • 举报
回复
哪有那么麻烦的,
String queryString1 = request.getParameter("yourparameter");
String queryString = new String(queryString1.getBytes("8859_1"),"gb2312");
虎叔 2000-09-13
  • 打赏
  • 举报
回复
试验一下新的jdk版本
前言 ............................................................................ xi 1. 教程 ......................................................................... 1 1.1. 第一部分 - 第一个 Hibernate 应用程序 ................................. 1 1.1.1. 设置 ............................................................ 1 1.1.2. 第一个 class ................................................... 3 1.1.3. 映射文件 ........................................................ 4 1.1.4. Hibernate 配置 .................................................. 7 1.1.5. 用 Maven 构建 .................................................. 9 1.1.6. 启动和辅助类 .................................................... 9 1.1.7. 加载并存储对象 ................................................. 10 1.2. 第二部分 - 关联映射 ................................................. 13 1.2.1. 映射 Person 类 ................................................ 13 1.2.2. 单向 Set-based 的关联 ......................................... 14 1.2.3. 使关联工作 ..................................................... 15 1.2.4. 值类型的集合 ................................................... 17 1.2.5. 双向关联 ....................................................... 18 1.2.6. 使双向连起来 ................................................... 19 1.3. 第三部分 - EventManager web 应用程序 ................................. 20 1.3.1. 编写基本的 servlet ............................................. 20 1.3.2. 处理与渲染 ..................................................... 21 1.3.3. 部署与测试 ..................................................... 24 1.4. 总结 ................................................................. 25 2. 体系结构(Architecture) ..................................................... 27 2.1. 概况(Overview) ...................................................... 27 2.2. 实例状态 .............................................................. 29 2.3. JMX 整合 ............................................................. 30 2.4. 对 JCA 的支持 ........................................................ 30 2.5. 上下文相关的会话(Contextual Session) ................................ 30 3. 配置 ........................................................................ 33 3.1. 可编程的配置方式 ...................................................... 33 3.2. 获得 SessionFactory .................................................. 34 3.3. JDBC 连接 ............................................................ 34 3.4. 可选的配置属性 ........................................................ 36 3.4.1. SQL 方言 ...................................................... 42 3.4.2. 外连接抓取(Outer Join Fetching) .............................. 43 3.4.3. 二进制流(Binary Streams) ..................................... 43 3.4.4. 二级缓存与查询缓存 ............................................. 43 3.4.5. 查询语言中的替换 ............................................... 43 3.4.6. Hibernate 的统计(statistics)机制 ............................. 43 3.5. 日志 ................................................................. 44 3.6. 实现 NamingStrategy .................................................. 44 3.7. XML 配置文件 ......................................................... 45 3.8. J2EE 应用程序服务器的集成 ............................................. 46 3.8.1. 事务策略配置 ................................................... 46HIBERNATE - Relational Persis... iv 3.8.2. JNDI 绑定的 SessionFactory ..................................... 47 3.8.3. 在 JTA 环境下使用 Current Session context(当前 session 上下文) 管理 .................................................................. 48 3.8.4. JMX 部署 ...................................................... 48 4. 持久化类(Persistent Classes) .............................................. 51 4.1. 一个简单的 POJO 例子 ................................................. 51 4.1.1. 实现一个默认的(即无参的)构造方法(constructor) ............. 52 4.1.2. 提供一个标识属性(identifier property)(可选) ................. 52 4.1.3. 使用非final的类(可选) ........................................ 53 4.1.4. 为持久化字段声明访问器(accessors)和是否可变的标志(mutators) (可选) .............................................................. 53 4.2. 实现继承(Inheritance) ............................................... 53 4.3. 实现 equals() 和 hashCode() 方法: ................................... 54 4.4. 动态模型(Dynamic models) ............................................ 55 4.5. 元组片断映射(Tuplizers) ............................................. 57 4.6. EntityNameResolvers ................................................... 58 5. 对象/关系据库映射基础(Basic O/R Mapping) ................................. 61 5.1. 映射定义(Mapping declaration) ....................................... 61 5.1.1. Doctype ........................................................ 62 5.1.2. Hibernate-mapping .............................................. 63 5.1.3. 类 ............................................................. 64 5.1.4. id ............................................................. 67 5.1.5. 增强的标识符生成器 ............................................. 71 5.1.6. 标识符生成器的优化 ............................................. 72 5.1.7. composite-id ................................................... 72 5.1.8. 鉴别器(discriminator) ........................................ 73 5.1.9. 版本(version)(可选) ........................................ 74 5.1.10. timestamp(可选) .............................................. 75 5.1.11. Property ...................................................... 76 5.1.12. 多对一(many-to-one) ......................................... 78 5.1.13. 一对一 ........................................................ 80 5.1.14. 自然 ID(natural-id) ......................................... 82 5.1.15. 组件(component)和动态组件(dynamic-component) ............... 82 5.1.16. 属性(Properties) ............................................ 83 5.1.17. 子类(subclass) .............................................. 84 5.1.18. 连接的子类(joined-subclass) ................................. 85 5.1.19. 联合子类(union-subclass) .................................... 86 5.1.20. 连接(join) .................................................. 87 5.1.21. Key ........................................................... 88 5.1.22. 字段和规则元素(column and formula elements) ................. 89 5.1.23. 引用(import) ................................................ 90 5.1.24. Any ........................................................... 90 5.2. Hibernate 的类型 ..................................................... 91 5.2.1. 实体(Entities)和值(values) ................................. 91v 5.2.2. 基本值类型 ..................................................... 92 5.2.3. 自定义值类型 ................................................... 93 5.3. 多次映射同一个类 ...................................................... 94 5.4. SQL 中引号包围的标识符 ............................................... 95 5.5. 其他元据(Metadata) ................................................ 95 5.5.1. 使用 XDoclet 标记 ............................................. 95 5.5.2. 使用 JDK 5.0 的注解(Annotation) .............................. 97 5.6. 据库生成属性(Generated Properties) ................................ 98 5.7. 字段的读写表达式 ...................................................... 98 5.8. 辅助据库对象(Auxiliary Database Objects) .......................... 99 6. 集合映射(Collection mappings) ............................................ 101 6.1. 持久化集合类(Persistent collections) ............................... 101 6.2. 集合映射( Collection mappings ) ................................... 102 6.2.1. 集合外键(Collection foreign keys) ........................... 103 6.2.2. 集合元素(Collection elements) ............................... 104 6.2.3. 索引集合类(Indexed collections) ............................. 104 6.2.4. 值集合于多对多关联(Collections of values and many-to-many associations) ....................................................... 105 6.2.5. 一对多关联(One-to-many Associations) ........................ 107 6.3. 高级集合映射(Advanced collection mappings) ......................... 108 6.3.1. 有序集合(Sorted collections) ................................ 108 6.3.2. 双向关联(Bidirectional associations) ........................ 109 6.3.3. 双向关联,涉及有序集合类 ...................................... 111 6.3.4. 三重关联(Ternary associations) .............................. 112 6.3.5. Using an ............................................. 112 6.4. 集合例子(Collection example) ....................................... 113 7. 关联关系映射 ............................................................... 117 7.1. 介绍 ................................................................ 117 7.2. 单向关联(Unidirectional associations) .............................. 117 7.2.1. 多对一(many-to-one) ......................................... 117 7.2.2. 一对一(One-to-one) .......................................... 117 7.2.3. 一对多(one-to-many) ......................................... 118 7.3. 使用连接表的单向关联(Unidirectional associations with join tables) .. 119 7.3.1. 一对多(one-to-many) ......................................... 119 7.3.2. 多对一(many-to-one) ......................................... 120 7.3.3. 一对一(One-to-one) .......................................... 120 7.3.4. 多对多(many-to-many) ........................................ 121 7.4. 双向关联(Bidirectional associations) ............................... 122 7.4.1. 一对多(one to many)/多对一(many to one) .................... 122 7.4.2. 一对一(One-to-one) .......................................... 123 7.5. 使用连接表的双向关联(Bidirectional associations with join tables) ... 124 7.5.1. 一对多(one to many)/多对一(many to one) .................... 124 7.5.2. 一对一(one to one) ......................................... 125 7.5.3. 多对多(many-to-many) ........................................ 126HIBERNATE - Relational Persis... vi 7.6. 更复杂的关联映射 ..................................................... 126 8. 组件(Component)映射 ....................................................... 129 8.1. 依赖对象(Dependent objects) ........................................ 129 8.2. 在集合中出现的依赖对象(Collections of dependent objects) ........... 131 8.3. 组件作为 Map 的索引(Components as Map indices ) .................... 132 8.4. 组件作为联合标识符(Components as composite identifiers) ............ 132 8.5. 动态组件(Dynamic components) ....................................... 134 9. 继承映射(Inheritance Mapping) ............................................ 137 9.1. 三种策略 ............................................................. 137 9.1.1. 每个类分层结构一张表(Table per class hierarchy) ............. 137 9.1.2. 每个子类一张表(Table per subclass) .......................... 138 9.1.3. 每个子类一张表(Table per subclass),使用辨别标志 (Discriminator) .................................................... 138 9.1.4. 混合使用“每个类分层结构一张表”和“每个子类一张表” ........... 139 9.1.5. 每个具体类一张表(Table per concrete class) .................. 140 9.1.6. 每个具体类一张表,使用隐式多态 ................................ 141 9.1.7. 隐式多态和其他继承映射混合使用 ................................ 142 9.2. 限制 ................................................................ 142 10. 与对象共事 ................................................................ 145 10.1. Hibernate 对象状态(object states) ................................. 145 10.2. 使对象持久化 ........................................................ 145 10.3. 装载对象 ............................................................ 146 10.4. 查询 ............................................................... 148 10.4.1. 执行查询 ..................................................... 148 10.4.2. 过滤集合 ..................................................... 152 10.4.3. 条件查询(Criteria queries) ................................. 153 10.4.4. 使用原生 SQL 的查询 ......................................... 153 10.5. 修改持久对象 ........................................................ 153 10.6. 修改脱管(Detached)对象 ............................................ 154 10.7. 自动状态检测 ........................................................ 155 10.8. 删除持久对象 ........................................................ 156 10.9. 在两个不同据库间复制对象 .......................................... 156 10.10. Session 刷出(flush) .............................................. 157 10.11. 传播性持久化(transitive persistence) ............................. 158 10.12. 使用元据 ......................................................... 160 11. Read-only entities ........................................................ 161 11.1. Making persistent entities read-only ................................ 162 11.1.1. Entities of immutable classes ................................ 162 11.1.2. Loading persistent entities as read-only ..................... 162 11.1.3. Loading read-only entities from an HQL query/criteria ......... 163 11.1.4. Making a persistent entity read-only ......................... 165 11.2. Read-only affect on property type .................................. 166 11.2.1. Simple properties ............................................ 167 11.2.2. Unidirectional associations .................................. 167
ant-1.6.2.jar asm-analysis-3.2.jar asm-commons-3.2.jar asm-tree-3.2.jar asm-util-3.2.jar aspectjweaver-1.7.4.jar avalon-framework-4.1.3.jar bsf-api-3.1.jar cache-api-0.4.jar cglib-nodep-2.2.jar citrus-webx-all-3.0.8.jar classworlds-1.1-alpha-2.jar classworlds-1.1.jar commons-beanutils.jar commons-cli-1.0.jar commons-collections-3.2.jar commons-digester-1.6.jar commons-httpclient-2.0.2.jar commons-io-1.3.2.jar commons-io-2.1.jar commons-lang-2.5.jar commons-logging-1.1.jar commons-validator-1.2.0.jar curator-framework-1.1.16.jar cxf-rt-frontend-simple-2.6.1.jar cxf-rt-transports-http-2.6.1.jar doxia-core-1.0-alpha-11.jar doxia-core-1.0.jar doxia-decoration-model-1.0-alpha-11.jar doxia-decoration-model-1.0.jar doxia-module-apt-1.0-alpha-11.jar doxia-module-apt-1.0.jar doxia-module-fml-1.0-alpha-11.jar doxia-module-fml-1.0.jar doxia-module-xdoc-1.0-alpha-11.jar doxia-module-xdoc-1.0.jar doxia-module-xhtml-1.0-alpha-11.jar doxia-module-xhtml-1.0.jar doxia-sink-api-1.0-alpha-10.jar doxia-sink-api-1.0-alpha-11.jar doxia-sink-api-1.0-alpha-4.jar doxia-sink-api-1.0.jar doxia-site-renderer-1.0-alpha-11.jar doxia-site-renderer-1.0.jar dummy.jar.zip dummy1.0.jar easymock-1.2_Java1.3.jar easymock-3.0.jar easymockclassextension-3.0.jar fastjson-1.1.31.jar fastjson-1.2.28.jar fastjson-1.2.31.jar file-management-1.2.1.jar fst-1.55.jar grizzly-core-2.1.4.jar hessian-lite-3.2.1-fixed-2.jar hibernate-validator-4.2.0.Final.jar hsqldb-1.7.1.jar htmlunit-1.9.jar httpclient-4.0.1.jar httpclient-4.1.2.jar httpclient-4.2.5.jar httpclient-4.4.jar httpcore-4.0.1.jar httpcore-4.1.2.jar jackson-core-2.8.8.jar jackson-core-asl-1.9.13.jar jackson-databind-2.3.3.jar jackson-datatype-joda-2.4.0.jar jackson-mapper-asl-1.9.12.jar javassist-3.20.0-GA.jar javax.ws.rs-api-2.0.1.jar jaxen-core-1.0-FCS.jar jaxen-jdom-1.0-FCS.jar jdependency-0.6.jar jdom-1.1.jar jedis-2.1.0.jar jetty-4.2.10.jar jetty-4.2.12.jar jfreechart-1.0.13.jar jmockit-0.999.8.jar jsch-0.1.23.jar jsch-0.1.27.jar jsr305-2.0.1.jar jtid

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧