Announcement Announcement Module
Collapse
No announcement yet.
spring mvc encoding setting ?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring mvc encoding setting ??

    how can i set the request encoding to be utf-8(the defualt is ISO8859-1)?
    what is more, i use "<form:input path="guideContent.maintopic"/>" the bind the data to an attribute of a object. This binding is also in ISO8859, can i also set it to be utf-8 ??

    Thank you very much!

  • #2
    can anyone help me?

    if the question is not described clearly, please point it out.
    thank you!

    Comment


    • #3
      See CharacterEncodingFilter

      Comment


      • #4
        what about request.setCharacterEncoding(&quot;utf-8&quot??

        But i have include the following:
        <%@ page language="java" pageEncoding="UTF-8"%>
        <%@ page session="false"%>
        <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
        <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
        <%response.setContentType("text/html;charset=utf-8");%>
        <%request.setCharacterEncoding("utf-8");%>

        If I don't use spring mvc , it works because of request.setCharacterEncoding("utf-8");%! So I think request.setCharacterEncoding("utf-8") is the same of CharacterEncodingFilter.
        Do you mean I must use CharacterEncodingFilter in spring mvc ?
        Thank you!

        Comment


        • #5
          Originally posted by handsomeli
          But i have include the following:
          <%@ page language="java" pageEncoding="UTF-8"%>
          <%@ page session="false"%>
          <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
          <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
          <%response.setContentType("text/html;charset=utf-8");%>
          <%request.setCharacterEncoding("utf-8");%>
          This only impacts the processing after this line. In other words, if your form submission processing logic is embeded in your jsp, and after that line, yes, it'll work. In Spring MVC's case, the binding process happens before the jsp view is rendered, so you have to set it somewhere before the binding happens.

          Comment


          • #6
            Solve the problem!

            Thank you manifoldronin!
            The encoding problem puzzled me for days. Without your tips , I may even had not yet sovle it .

            Thank you manifoldronin!

            Comment


            • #7
              The Filter seems to be out of date. Didn't find any information about this filter in the current documentation of Spring.

              How can i now set the Encoding to UTF-8??

              Comment

              Working...
              X