报错:
org.apache.jasper.JasperException: /WEB-INF/jsp/common/top.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])org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:292)org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:115)org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:140)org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:579)org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389)org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2441)org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2447)org.apache.jasper.compiler.Node$Root.accept(Node.java:470)org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389)org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2441)org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:106)org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:643)org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389)org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2441)org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2447)org.apache.jasper.compiler.Node$Root.accept(Node.java:470)org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2389)org.apache.jasper.compiler.Validator.validateDirectives(Validator.java:1817)org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:203)org.apache.jasper.compiler.Compiler.compile(Compiler.java:385)org.apache.jasper.compiler.Compiler.compile(Compiler.java:362)org.apache.jasper.compiler.Compiler.compile(Compiler.java:346)org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:603)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:399)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)javax.servlet.http.HttpServlet.service(HttpServlet.java:741)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:168)org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257)org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)javax.servlet.http.HttpServlet.service(HttpServlet.java:634)org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)javax.servlet.http.HttpServlet.service(HttpServlet.java:741)org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
包含页面的是:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
被包含页面:
<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
果然contentType="text/html;和charset=utf-8"之间多了一个空格,把两个文件第一行的@page内容改为一致,再执行程序,运行通过。
总结:
被包含页面和包含页面必须都加上@page 头内容这个asp正好相反的,而且值要一致如果你是 <%@ include file="/WEB-INF/jsp/common/head.jsp"%>
那么改为<jsp:include page="/WEB-INF/jsp/common/head.jsp" >如果你是<jsp:include page="/WEB-INF/jsp/common/head.jsp" >
那么改为<%@ include file="/WEB-INF/jsp/common/head.jsp"%>