€ symbol not defined

前端 未结 2 1158
执笔经年
执笔经年 2020-12-11 12:49

I have a list in my action which I field by values saved on a MySql DB.

I only have one object stored, which has designation .

In jsp when I do

相关标签:
2条回答
  • 2020-12-11 13:37

    If the page encoding is not defined, the default is (the equivalent of the JSP page directive):

    <%@page contentType="text/html; charset=ISO-8859-1" %>
    

    The encoding you want is not ISO-8859-1, but UTF-8, that supports any language (take a look at Table 23-2 Valid Values for the IANA-Defined Character Set).

    You can set your page, request and response encoding in three ways:

    1. Setting the contentType in each JSP:

      <%@page contentType="text/html; charset=UTF-8" %>
      
    2. Setting the pageEncoding in each JSP:

      <%@page pageEncoding="UTF-8" %>
      
    3. Setting the <jsp-property-group> once in web.xml:

      <jsp-config>
          <jsp-property-group>
              <url-pattern>*.jsp</url-pattern>
              <page-encoding>UTF-8</page-encoding>            
          </jsp-property-group>
      </jsp-config>
      

    The HTML <meta> tag will be generated accordingly. Remember to not specify different encodings when unnecessarily using both pageEncoding and <jsp-property-group>, it is a translation-time error.

    For more info about this, read the Oracle docs (pretty old, but still true).

    0 讨论(0)
  • 2020-12-11 13:46

    Place this on the top of the JSP page. Symbols in UTF-8 encoding displays better than ?.

    <%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
    
    0 讨论(0)
提交回复
热议问题