JSP处理乱码异常

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"%>//正确的写法

你可能感兴趣的:(JSP处理乱码异常)