关于分页传中文参数乱码的问题,急!
小弟正在做一个查询
<s:form action="SearchAllPassedResource.action" method="post">
<input type="text" name="selectname" />
<s:select size="1" name="selectmethod" list="#{'1':'按资源名称查找','2':'按关键字查找','3':'按资源类别查找','4':'按上传人姓名查找'}" theme="simple" />
<input name="Submit4" type="submit" value="搜 索" />
</s:form>
其中查询条件"selectname"可能为中文,小弟疑惑的事,我这样表单直接提交,就算有中文,也可以将条件"selectname"提交到后台action,并且不出现乱码。但是如果查询结果进行分页:
<a href="<s:url value="SearchAllPassedResource1.action">
<s:param name="currentPage" value="currentPage"/>
<s:param name="pagerMethod" value="'next'"/>
<s:param name="selectmethod" value="%{selectmethod}"/>
<s:param name="selectname" value="%{selectname}"/>
</s:url>">下一页</a>
将分页的参数再传到后台的action后就会出现中文乱码。我现在的解决方法是后台写两个函数:SearchAllPassedResource和SearchAllPassedResource1分别处理表单提交的和分页传值的中文参数,后者加入编码转换:this.selectname = new String(selectname.getBytes("ISO8859_1"), "UTF-8");注:如果将此代码写在第一个函数里,那原本正常的中文参数反而会变成乱码!请问各位高手,有没有方法使我能用一个函数去处理两个不同情况(中文乱码和不乱码)呢?