随笔 - 6  文章 - 129  trackbacks - 0
<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(14)

随笔档案(6)

文章分类(467)

文章档案(423)

相册

收藏夹(18)

JAVA

搜索

  •  

积分与排名

  • 积分 - 814157
  • 排名 - 49

最新评论

阅读排行榜

评论排行榜

今天在做图书查询时,想让查询的条件通过GET的方式提交到相应的action里.

问题是中文数据提交到action里都成了乱码.

用post提交时,并不会出现上面提到的乱码问题.

请问该怎样解决提交用GET提交的乱码问题?


struts.xml已经设置了
<constant name="struts.i18n.encoding" value="GBK" />
JSP页面也设置了
<%@ page language="java" contentType="text/html; charset=GBK"%>
<s:form action="search.action" method="get">
      <input type="hidden" name="order" value="hit">
   <table>
    <tr>
     <td><s:textfield label="书名" name="bookName"/></td>
    </tr>
    <tr>
     <td><s:textfield label="作者" name="authorName"/></td>
    </tr>
    <tr>
     <td><s:textfield label="出版社" name="publishName"/></td>
    </tr>
    <tr>
     <td>
          <s:select label="折扣" list="#{0:'请选择折扣',1:'30折以上',2:'30折到50折',3:'50折到70折',4:'70折以下'}"
             listKey="key" listValue="value">
          </s:select>
       </td>
    </tr>
    <tr>
     <td align="center"><input type="submit" value="确定"></td><td align="center"><input type="reset" value="重新填写"></td>
    </tr>
   </table>
    </s:form>
在SearchAction里输出查询条件.比如说图书名称.在控制台都成了乱码



posted on 2007-11-22 14:14 Ke 阅读(4180) 评论(4)  编辑  收藏 所属分类: 问题区

FeedBack:
# re: struts2表单(method=get)乱码问题[未登录] 2008-01-12 10:04 KE
问题解决了
只需要对查询条件的字符内容进行编码就行了.
new String(searchStr.getBytes("ISO-8859-1"))  回复  更多评论
  
# re: struts2表单(method=get)乱码问题 2008-08-28 11:30  漂竹
这个解决。。。。你不觉得麻烦吗?期待更好的解决方案  回复  更多评论
  
# re: struts2表单(method=get)乱码问题 2008-10-16 15:15 ffychina
在tomcat 的server.xml 的connector节点增加属性: URIEncoding="UTF-8  回复  更多评论
  
# re: struts2表单(method=get)乱码问题 2008-10-25 21:31 KE
@ffychina
是个不错的方法有空试试,谢了!
  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: