我正在尝试在Tomcat服务器上运行jsp页面,但我一直收到此错误:
HTTP状态500 - 不支持的编码:
这是我的jsp文件:
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="mod.catal.*" %>
<%@ page import="pres.beans.*" %>
<html>
<head>
enter code here<title>Catégories</title>
</head>
<body bgcolor="#FFFFFF">
<% CategorieForm cf=(CategorieForm)session.getAttribute("catForm");%>
<form method='post' action='catalogue'>
<table border='1' align='center'>
<tr>
<td>Chercher une catégorie:<input type='text' name='motCle' value='<%=(cf!=null)?cf.getMotCle():"" %>'></td>
<td><input type='submit' name='chercheCat' value='Chercher'></td>
</tr>
</table>
</form>
<form method='post' action='catalogue'>
<table border='1' align='center'>
<tr>
<td>Id Catégorie<td>Nom Catégorie</td><td>Description</td>
</tr>
<tr>
<td></td>
<td><input type='text' name='nomCat'></td>
<td><input type='text' name='description' size='40'></td>
<td><input type='submit' name='addCat' va<%@ page contentType="text/html; charset=" %><%@ page contentType="text/html; charset=" %>lue='Ajouter'></td>
</tr>
<% if(cf!=null){
Iterator<Categorie> lesCat=cf.getLesCat().iterator();
while (lesCat.hasNext()){
Categorie cat=(Categorie)lesCat.next();%>
<tr>
<td><%=cat.getIdCat()%></td>
<td><%=cat.getTitre()%></td>
<td><%=cat.getDescription()%></td>
<td><a href='catalogue?idCat=<%=cat.getIdCat()%>'>Supprimer</a></td>
</tr>
<%
}
}
%>
</table>
</form>
</body>
</html>
这是我的控制台:
org.apache.jasper.JasperException: Unsupported encoding:
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
at org.apache.jasper.compiler.JspUtil.getReader(JspUtil.java:1120)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:250)
at org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:120)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:180)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
我曾尝试在jsp文件中添加一个定义编码类型的标头,但我仍然使用void编码类型获得* Unsupported encoding:* 。
答案 0 :(得分:1)
不要忘记JSP的contenType声明中的charset。所以
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>