JSP处理乱码异常

来源:互联网 发布:mac实用工具怎么打开 编辑:程序博客网 时间:2024/04/29 10:42

jsp的错误:

org.apache.jasper.JasperException: /Conn.jsp(1,2) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html; charset=gb2312, new: text/html;charset=gb2312)org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)

left.jsp(1,2) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html;charset=UTF-8, new: text/html; charset=UTF-8)

错误主要看这句: (old: text/html;charset=UTF-8, new: text/html; charset=UTF-8)

正确做法是:被包含的jsp,要与当前页<%@ page/>内容要一致,不允许contentType="text/html; charset=UTF-8",有空格。

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>//这是我错误的写法。

 

<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>//正确的写法

原创粉丝点击