Permalink
Browse files

Fix 2832553

  • Loading branch information...
1 parent 20e2b16 commit c439927908ebf7f3f4c24a073e59e9f5816144c1 @aalmiray committed Dec 2, 2010
View
@@ -45,4 +45,4 @@ sourceSets {
groovy.srcDirs = []
classesDir = "$buildDir/classes/jdk15" as File
}
-}
+}
@@ -79,7 +79,7 @@
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
- <version>2.2.2</version>
+ <version>2.3</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
@@ -37,7 +37,7 @@
*/
public class JsonView extends AbstractView {
/** Default content type. Overridable as bean property. */
- private static final String DEFAULT_JSON_CONTENT_TYPE = "application/json";
+ private static final String DEFAULT_JSON_CONTENT_TYPE = "application/json;charset=UTF-8";
private boolean forceTopLevelArray = false;
private boolean skipBindingResult = true;
/** Json confiiguration */
@@ -130,6 +130,20 @@ public void testForceTopLevelArray() throws Exception {
jsTester.assertEquals( "json[0].str", "'string'" );
}
+ public void testCharEncoding() throws Exception {
+ JsonView view = new JsonView();
+ view.setForceTopLevelArray( true );
+ Map model = new HashMap();
+ model.put( "unicodestring", "\u5718\u9AD4\u6236\u53E3\u9A57\u8B49\u7A0B\u5E8F" );
+
+ view.render( model, servletRequest, servletResponse );
+ jsTester.eval( toJsScript( servletResponse ) );
+
+ jsTester.assertNotNull( "json" );
+ jsTester.assertIsArray( "json" );
+ jsTester.assertEquals( "json[0].unicodestring", "'\u5718\u9AD4\u6236\u53E3\u9A57\u8B49\u7A0B\u5E8F'" );
+ }
+
protected void setUp() throws Exception {
servletContext = new MockServletContext();
StaticWebApplicationContext wac = new StaticWebApplicationContext();
@@ -1,6 +1,7 @@
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=[%d{yy-MM-dd HH:mm:ss}] %-5p [%-30.30c{1}:%L] %m%n
+log4j.appender.console.Encoding=UTF-8
log4j.rootLogger=WARN, console
log4j.category.net.sf.json = DEBUG
log4j.category.net.sf.jstester = DEBUG

0 comments on commit c439927

Please sign in to comment.