BlogJava 联系 聚合 管理  

Blog Stats

文章档案


hanbing

json被定义undefined的问题:

<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
 <constant name="struts.i18n.encoding" value="UTF-8"/>
 <package name="example"  extends="json-default">
  <action name="JSONExample" class="lee.JSONExample">
   <result type="json"/>
  </action>
 </package>
</struts>
在上面配置文件中有两个值得注意的地方:


第一个地方是配置struts.i18n.encoding常量时,不再是使用GBK编码,而是UTF-8编码,这是因为Ajax的POST请求都是以UTF-8的方式进行编码的。
第二个地方是配置包时,自己的包继承了json-default包,而不再继承默认的default包,这是因为只有在该包下才有json类型的Result。
posted on 2008-10-21 12:41 睡得惊动了党 阅读(200) 评论(0)  编辑  收藏

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


网站导航: