struts2中文问题
说起来,接触struts2也已经差不多半个月了,虽然期间断断续续的看过一些书,但是花的时间并不多,认识也不是很到位。但是工作需要,也顾不了那么多了。struts2在中文的处理方面并没提供多大帮助,虽然内置个
<constant name="struts.i18n.encoding" value="UTF-8" />
<tr><td><s:property /></td><td><a href="<s:url value='download.action'> <s:param name='fileName' value='fileFileName[#fn.getIndex()]'/> </s:url>">下载</a></td></tr>
getRequest().getCharacterEncoding()
String chineseFileName = new String(fileName.getBytes("ISO8859-1"),"UTF-8");public String getDownloadChineseFileName() throws UnsupportedEncodingException {String downloadChineseFileName = fileName;String chineseFileName = new String(fileName.getBytes("ISO8859-1"),"UTF-8");return downloadChineseFileName;}<action name="download" type="stream"><param name="contentType">application/octet-stream</param><param name="inputName">downloadFile</param><param name="contentDisposition">attachment;filename="${downloadChineseFileName}"</param></result></action>public String getDownloadChineseFileName() throws UnsupportedEncodingException {return fileName;}public String getDownloadChineseFileName() throws UnsupportedEncodingException {String downloadChineseFileName = fileName;String chineseFileName = new String(fileName.getBytes("ISO8859-1"),"UTF-8");downloadChineseFileName = new String( chineseFileName.getBytes(), "ISO8859-1" );return downloadChineseFileName;}<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" useBodyEncodingForURI="true" URIEncoding="UTF-8" compression="on" compressionMinSize="2048" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/xml"/>downloadName = URLEncoder.encode(downloadName, Constants.ENCODING);