If I pass variables with extended characters to my JSP, the end of the rendered file is truncated by 2 bytes for each non-ascii character. Why is this so? Here is an example.
My Controller:
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class CharTestController {
@RequestMapping(value="/chartest.do")
public String handleRequest(ModelMap model) throws Exception {
char var1=9829; // Heart Char
String var2="™"; // TM symbol
model.addAttribute("var1", var1);
model.addAttribute("var2", var2);
return "chartest";
}
}
My JSP:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
${var1} <c:out value="${var1}" />
${var2} <c:out value="${var2}" />
9876543210
My Output:
♥ ♥ ™ ™ 98
Regardless if I use or just print the variable, since I printed 4 chars, 8 bytes are missing from the end. Any ideas?