jsp页面调用js中文乱码
我在jsp页面里调用那个日历的控件,也就是一个js写的文件,但是在jsp页面调用后
显示出来其中的年、月、日、星期等都是乱码,jsp页面的编码是GB2312了
网上说web.xml中加入下列代码,但有错误
<jsp-config>
<jsp-property-group>
<description>
Special property group for JSP Configuration JSP example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
<description>
Special property group for JSP Configuration JSP example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.html</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
<description>
Special property group for JSP Configuration JSP example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.txt</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
<description>
Special property group for JSP Configuration JSP example.
</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.js</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
</jsp-property-group>
</jsp-config>
------解决方案--------------------如果是myeclips或者eclipse的话,可以自己把编码设置的,不用在配置文件里面写.
你这样写了过后,不知道要读好久才能读懂...
------解决方案--------------------解决乱码问题涉及的地方比较多,就你目前谈到的问题,我们可以用以下方式解决:
1. 确定一种编码方式,不管是Utf-8,还是GBK、gb2312.。我以utf-8为例进行说明。
2. 用Editplus打开js文件,如果中文正常,就另存为一下,把编码修改为utf-8,覆盖原来的文件。
3. jsp文件里统一一下编码方式为utf-8。两个地方:
<%@ page language="java" contentType="text/html;charset=utf-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
通常这样就没有问题了。
------解决方案--------------------试一下下边的情况!注意红色部门