JSP引用JS文件中文乱码问题

1.首先确认页面,mate,js的编码是否一致.可作如下设置:

<%@ page language="java" import="java.util.*" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>


还要注意js里面是否引用了其他的js,用的编码是否一致.


2.如果还是乱码,可在web.xml中作如下配置:


         
             
                  Special property group for JSP Configuration JSP example.
             
             JSPConfiguration
             *.jsp
             true
             UTF-8
             false
             
             
             
                  Special property group for JSP Configuration JSP example.
             
             JSPConfiguration
             *.html
             true
             UTF-8
             false
             
             
             
                  Special property group for JSP Configuration JSP example.
             
             JSPConfiguration
             *.txt
             true
             UTF-8
             false
             
             
             
                  Special property group for JSP Configuration JSP example.
             
             JSPConfiguration
             *.js
             true
             UTF-8
             false
             
             
         
     

使用这种配置的时候要注意是否会影响到其他页面.

你可能感兴趣的:(j2ee)