最近写jsp遇到一系列的低级错误,记录下来权当前车之鉴吧。

错误提示:

SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /jsp04/Zj04_sj_test1_1.jsp(2,1) Page directive must not have multiple occurrences of pageencoding

程序代码如下:

 <%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page language="java" import="jsp04.*" pageEncoding="gbk"%>
<%@ page import="javax.servlet.jsp.jstl.sql.Result;"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>民意调查</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--> </head> <body>
<br>
在校大学生是否适合做兼职 <br>
<br>
<%
//构造sql语句,取出调查
String sql="select * from surveyItem where surveyID=1";
Object params[]={};
//获取调查项列表
Result result=DBHelp.runSelectSql(sql,params);
Map[] rows=result.getRows();
//循环访问每一个调查项
for(int i=0;i<rows.length;i++){
//得到调查项目的ID
int id=Integer.parseInt(rows[i].get("id").toString());
//得到调查项
String item=rows[i].get("item").toString();
%>
<input type="radio" name="radsurver" value="<%=id %>"><%=item %>
<%
}
%><br>
<input type="submie" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置">
</body>
</html>
首先,org.apache.jasper.JasperException 中的JasperException
这个异常时jsp引擎解析jsp页面生成servlet时产生的,故错误是在转译阶段,应该是页面的语法有问题,而不是执行阶段出错
然后,检查一下配置,发现页面编码设置了两次,虽然是一样的编码,但还是不被允许的
最后,第二行改为:
  
<%@ page import="jsp04.*" %>

OK  !

org.apache.jasper.JasperException: - Page directive must not have multiple occurrences of pageencoding的更多相关文章

  1. org.apache.jasper.JasperException: /WEB-INF/view/../../../common/common1.jsp (line: 7, column: 1) Page directive must not have multiple occurrences of pageencoding

    本文为博主原创,未经允许,不得转载: 先还原错误: org.apache.jasper.JasperException: /WEB-INF/view/../../../../common/common ...

  2. Page directive must not have multiple occurrences of pageencoding

    一个jsp文件中不能同时出现两个 p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #932192 } pageE ...

  3. Page directive: illegal to have multiple occurrences of contentType with different values

    org.apache.jasper.JasperException: /commons/meta.jsp(1,1) PWC5988: Page directive: illegal to have m ...

  4. Struts2报错org.apache.jasper.JasperException: Invalid directive原因

    struts标签书写错误.<s:textfield name="us.username"/>对的<s:textfield name="us.userna ...

  5. 解决报错 Page directive: illegal to have multiple occurrences of contentType with different values (old:

    转自:https://blog.csdn.net/dorothy1224/article/details/78064288

  6. 报错:org.apache.jasper.JasperException: /jsp/head.jsp (line: 1, column: 2) Page directive: illegal to

    上面报错提示的是org.apache.jasper.JasperException: /jsp/head.jsp (line: 1, column: 2) Page directive: illega ...

  7. org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/jiaoshi/daochuEx

    org.apache.jasper.JasperException: An exception occurred processing JSP page /admin/jiaoshi/daochuEx ...

  8. JSP异常之org.apache.jasper.JasperException(转)

    According to TLD or attribute directive in tag file, attribute items does not accep t any expression ...

  9. org.apache.jasper.JasperException: Expecting "jsp:param" standard action with "name" and "value" attributes

      jasper  英 ['dʒæspə]  美 ['dʒæspɚ] 跟读 口语练习 n. 碧玉:墨绿色 n. (Jasper)人名:(德)雅斯佩尔:(西)哈斯佩尔 JasperException 异 ...

随机推荐

  1. Centos7下安装部署MXNET

    Centos下安装MXNET,参考官方文档http://mxnet.io/get_started/setup.html#prerequisites, 一.安装python的mxnet步骤如下: #!/ ...

  2. Ace Admin 使用教程

    (原) 公司项目要换框架,然后丢了一套国外的给我,ace admin,本想着拿来改改,翻翻百度就能用的,可它是国外的啊,国内普及率又不高,没办法,硬着头皮一点点啃英文文档吧. File(文件) 简介: ...

  3. react 的五脏六腑ing~

    用react一年多了.一直是在别人的影子下写的代码,他们也确实都是大神级的人物,不过,小菜鸟也有小菜鸟的思想~这不,今天就在重温一遍react!记一些零碎的知识点~不知道对你们有没有用,不过,对于我, ...

  4. C语言之字符串

    什么是字符串:使用双引号包含的字符序列. 简单的字符串"hello world" 一个'h'是一个字符 很多个字符组合在一起就是字符串了 字符串与字符数组 在C语言中没有专门的字符 ...

  5. python学习之爬虫(一) ——————爬取网易云歌词

    接触python也有一段时间了,一提到python,可能大部分pythoner都会想到爬虫,没错,今天我们的话题就是爬虫!作为一个小学生,关于爬虫其实本人也只是略懂,怀着"Done is b ...

  6. 第39篇 免费博客github Pages绑定域名

    原文地址:http://blog.laofu.online/2017/06/02/how-bind-domain/ 网站已经有了,需要对网站来绑定一个自己的个性域名,本人是买了一个阿里云的域名,也就是 ...

  7. 每天一个JS 小demo之“随机”抽奖。主要知识点:Math函数,数组方法,递归

    <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"& ...

  8. sublime text 快捷收集

    1. 文件快速导航: 这是sublime上面很好用的功能之一,ctrl+p可以调出窗口,菜单上的解释是gotoanythings ,确实如其所言,调出窗口后,直接输入关键字,可以在已打开的项目文件夹中 ...

  9. 用java实现简单快速的webservice客户端/数据采集器(支持soap1.1和soap1.2标准,支持utf-8编码)

    前言: 用了cxf,axis等各种wbeservice实现库,简单试用了一下动态调用的方式,很不满意,完全无法满足业务的需要,所以自己实现了一个webservice采集客户端,方便动态调用外部webs ...

  10. SQL Server使用导入导出向导导入超过4000个字符的字段的数据

    在使用SQL Server导入导出向导导入数据的时候,我们经常会碰到某个单元格的数据超长而被截断报错的情况.本文针对这种场景给出相应的解决方案.   环境描述:SQL Server 2012,文件源: ...