struts2和json集成编码问题
小菜学struts2 ,据说编码格式必须为 <constant name= "struts.i18n.encoding " value= "UTF-8 "> </constant>
但是我写的程序,如果是gbk,可以运行json ,但是如果是utf-8 ,则没反应,奇怪了
配置文件
<constant name= "struts.custom.i18n.resources " value= "messageResource "> </constant>
<!-- 定义web应用的默认编码集 -->
<constant name= "struts.i18n.encoding " value= "UTF-8 "> </constant>
<!-- 定义可以动态method模式进行Action访问 -->
<constant name= "struts.enable.DynamicMethodInvocation " value= "true "> </constant>
<constant name= "struts.ui.theme " value= "simple " />
<constant name= "struts.ui.templateDir " value= "template " />
<constant name= "struts.ui.templateSuffix " value= "ftl " />
<constant name= "struts.locale " value= "zh_CN "> </constant>
<!-- 使用ajaxaction处理类的跳转结果 -->
<action name= "validName " class= "com.hbxyf.action.UserAjaxAction ">
<result type= "json " />
<interceptor-ref name= "defaultStack " />
</action>
<%@ page language= "java " import= "java.util.* " pageEncoding= "utf-8 "%>
<%@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>
<base href= " <%=basePath%> ">
<title> 用户添加 </title>
<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
<meta http-equiv= "keywords " content= "keyword1,keyword2,keyword3 ">
<meta http-equiv= "description " content= "This is my page ">
<LINK rel= "stylesheet " type= "text/css " href= "navigation/stylee.css ">
<script src= "sxhtml/prototype-1.4.0.js " type= "text/javascript "> </script>
<script src= "sxhtml/json.js " type= "text/javascript "> </script>
<script language= "JavaScript ">
function validateName()
{
document.getElementById( "tip ").innerHTML = " ";
if(document.getElementById( "login ").value== " "){
return ;
}
//请求的地址
var url =