一、服务端两种处理中文的方式
1.Action写法
private
String showMessage;
//
公有属性
![]()
//
第一种处理编码方式
this
.showMessage
=
URLEncoder.encode(
"
删除所有采集数据成功!!
"
,
"
UTF-8
"
);
![]()
//第二种处理编码方式
BASE64Encoder encode = new BASE64Encoder();
this
.showMessage
=
encode.encode(
"
数据成功!!
"
.getBytes(
"
UTF-8
"
));
return "toPromp";
2.strutx.xml
<
global-results
>
<
result
name
="error"
type
="redirect"
>
/common/500.jsp
</
result
>
<
result
name
="notFund"
type
="redirect"
>
/common/404.jsp
</
result
>
<
result
name
="toPromp"
type
="redirect"
>
/common/prompt.jsp?source=${source}
&
showMessage=${showMessage}
</
result
>
</
global-results
>
3.前台页面
<%
@ page language
=
"
java
"
pageEncoding
=
"
UTF-8
"
%>
<%
@page
import
=
"
sun.misc.BASE64Decoder
"
%>
<%
@ taglib prefix
=
"
s
"
uri
=
"
/struts-tags
"
%>
<%
String path
=
request.getContextPath();
String basePath
=
request.getScheme()
+
"
://
"
+
request.getServerName()
+
"
:
"
+
request.getServerPort()
+
path
+
"
/
"
;
%>
<!
DOCTYPE HTML PUBLIC
"
-//W3C//DTD HTML 4.01 Transitional//EN
"
>
<
html
>
<
head
>
<
meta http
-
equiv
=
"
Content-Type
"
content
=
"
text/html; charset=UTF-8
"
>
<
title
>
信息提示
</
title
>
<
base href
=
"
<%=basePath %>
"
>
<
STYLE type
=
"
text/css
"
>

a
{ text-decoration: none; color: #002280 }

a:hover
{ text-decoration: underline }

body
{ font-size: 9pt; }

table
{ font: 9pt Tahoma, Verdana; color: #000000 }

.header
{ font: 9pt Tahoma, Verdana; color: #FFFFFF; font-weight: bold; background-color: #98D745 }

.header a
{ color: #FFFFFF }

.tableborder
{ background: #CDE2F8; border: 1px solid #98D745 }
</
STYLE
>
<
SCRIPT language
=
javascript
>
var secs
=
3
;
//
3秒
for
(i
=
1
;i
<=
secs;i
++
)

{
window.setTimeout("update(" + i + ")", i * 1000);}
function update(num)

{
if(num == secs)

{
window.location.href="<%=basePath %><s:property value="#parameters.source"/>";
}
}
</
SCRIPT
>
</
head
>

<
body
>
<
br
>
<
br
>
<
br
>
<
br
>
<
br
>
<
br
>
<
table width
=
"
500
"
border
=
"
0
"
align
=
"
center
"
cellpadding
=
"
3
"
cellspacing
=
"
1
"
class
=
"
tableborder
"
>
<
tr
class
=
"
header
"
>
<
td height
=
"
25
"
>
<
div align
=
"
center
"
>
信息提示
</
div
>
</
td
>
</
tr
>
<
tr bgcolor
=
"
#FFFFFF
"
>
<
td height
=
"
80
"
>
<
div align
=
"
center
"
>
<
br
>
<
b
>
<%
BASE64Decoder d
= new
BASE64Decoder();
String temp = new String(d.decodeBuffer(request.getParameter("showMessage")), "UTF-8"
);
out.println(temp);
%>
</
b
>
<
br
>
<
br
>
<
a href
=
"
<s:property value=
"
#parameters.source
"
/>
"
>
如果您的浏览器没有自动跳转,请点击这里
</
a
>
<
br
>
<
br
>
</
div
>
</
td
>
</
tr
>
</
table
>
</
body
>
</
html
>
<%
@ page language
=
"
java
"
contentType
=
"
text/html; charset=UTF-8
"
pageEncoding
=
"
UTF-8
"
%>
<%
@page
import
=
"
java.net.URLDecoder
"
%>
<%
@ taglib prefix
=
"
s
"
uri
=
"
/struts-tags
"
%>
<%
String path
=
request.getContextPath();
String basePath
=
request.getScheme()
+
"
://
"
+
request.getServerName()
+
"
:
"
+
request.getServerPort()
+
path
+
"
/
"
;
%>
<!
DOCTYPE HTML PUBLIC
"
-//W3C//DTD HTML 4.01 Transitional//EN
"
>
<
html
>
<
head
>
<
meta http
-
equiv
=
"
Content-Type
"
content
=
"
text/html; charset=UTF-8
"
>
<
title
>
信息提示
</
title
>
<
base href
=
"
<%=basePath %>
"
>
<
STYLE type
=
"
text/css
"
>
![]()
a
{ text-decoration: none; color: #002280 }
![]()
a:hover
{ text-decoration: underline }
![]()
body
{ font-size: 9pt; }
![]()
table
{ font: 9pt Tahoma, Verdana; color: #000000 }
![]()
.header
{ font: 9pt Tahoma, Verdana; color: #FFFFFF; font-weight: bold; background-color: #98D745 }
![]()
.header a
{ color: #FFFFFF }
![]()
.tableborder
{ background: #CDE2F8; border: 1px solid #98D745 }
</
STYLE
>
<
SCRIPT language
=
javascript
>
var secs
=
2
;
//
2秒
for
(i
=
1
;i
<=
secs;i
++
)
![]()
{
window.setTimeout("update(" + i + ")", i * 1000);}
function update(num)
![]()
{
if(num == secs)
![]()
{
window.location.href="<%=basePath %><s:property value="#parameters.source"/>";
}
}
</
SCRIPT
>
</
head
>
![]()
<
body
>
<
br
>
<
br
>
<
br
>
<
br
>
<
br
>
<
br
>
<
table width
=
"
500
"
border
=
"
0
"
align
=
"
center
"
cellpadding
=
"
3
"
cellspacing
=
"
1
"
class
=
"
tableborder
"
>
<
tr
class
=
"
header
"
>
<
td height
=
"
25
"
>
<
div align
=
"
center
"
>
信息提示
</
div
>
</
td
>
</
tr
>
<
tr bgcolor
=
"
#FFFFFF
"
>
<
td height
=
"
80
"
>
<
div align
=
"
center
"
>
<
br
>
<
b
>
<%
String temp
=
URLDecoder.decode(request.getParameter(
"showMessage"),"utf-8"
);
out.println(temp);
%>
</
b
>
<
br
>
<
br
>
<
a href
=
"
<s:property value=
"
#parameters.source
"
/>
"
>
如果您的浏览器没有自动跳转,请点击这里
</
a
>
<
br
>
<
br
>
</
div
>
</
td
>
</
tr
>
</
table
>
</
body
>
</
html
>
弄了半天,还是解决不了问题,把改配置的都配了,为什么还是不行呢,我晕,最好才发现,Tomcat服务器下,不支持浏览器带中文,需要设置一个东西 就是Service里面设置 :
<
Connector
port
="8080"
protocol
="HTTP/1.1"
connectionTimeout
="20000"
redirectPort
="8443"
URIEncoding
="UTF-8"
/>
1.Action写法
//第二种处理编码方式
BASE64Encoder encode = new BASE64Encoder();
return "toPromp";
2.strutx.xml
3.前台页面






















































































弄了半天,还是解决不了问题,把改配置的都配了,为什么还是不行呢,我晕,最好才发现,Tomcat服务器下,不支持浏览器带中文,需要设置一个东西 就是Service里面设置 :
名称: ♪4C.ESL | .↗Evon
口号: 遇到新问题♪先要寻找一个方案乄而不是创造一个方案こ
mail: 联系我