doGet() throws NamingException报错
做一个通过JNDI查找资源的小练习,Context = new InitialContext(),发现NamingException异常,eclipse编辑器只有catch的提示,没有throws的提示,强行在doGet()方法后throws NamingException会报"Exception NamingException is not compatible with throws clause in HttpServlet.doGet(HttpServletRequest, HttpServletResponse)"。
原因:查看HttpServlet中的doGet方法源码,

根据方法重写的原则,子类重写父类方法时,抛出的异常不能超过父类的范畴,因此在本例中,只能throws ServletException和IOEXception,其他异常必须catch使得编译通过。
doGet() throws NamingException报错的更多相关文章
- maven项目install时候一直报错,检查Maven-javadoc-plugin声明错误(Java 8 配置Maven-javadoc-plugin)或者是:警告: @throws 没有说明
在升级JDK至1.8之后,使用Maven-javadoc-plugin插件打包报错,[ERROR] Failed to execute goal org.apache.maven.plugins:ma ...
- 为什么我的子线程更新了 UI 没报错?借此,纠正一些Android 程序员的一个知识误区
开门见山: 这个误区是:子线程不能更新 UI ,其应该分类讨论,而不是绝对的. 半小时前,我的 XRecyclerView 群里面,一位群友私聊我,问题是: 为什么我的子线程更新了 UI 没报错? 我 ...
- tomcat使用cookies缓存的时候中文报错解决办法 java.lang.IllegalArgumentException: Control character in cookie value or attribute.
报错出现 java.lang.IllegalArgumentException: Control character in cookie value or attribute. at org.apac ...
- 解决tomcat报错javax.imageio.IIOException: Can't create output stream!
启动tomcat catalina.out报错如下,登陆的时候无法显示验证码 2017-06-09 11:23:06,628 DEBUG org.springframework.web.servlet ...
- springboot 1.5.x 使用tomcat8设置cookie的domain以dot开头报错
"C:\Program Files\Java\jdk1.7.0_75\bin\java" -XX:TieredStopAtLevel=1 -noverify -Dspring.ou ...
- 为什么这个地方用重定向会报错.只能用 服务器跳转?? 为什么我加了过滤器,还是能直接登陆 servlet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, ...
- CheckStyle报错的常见问题及解决方式
CheckStyle报错的常见问题及解决方式 声明: 本文摘自百度文库.希望这篇文章提到的规范能对大家编程起到好的效果,此文不定期更新,将推出更加详尽的编程规范. 1 提示:Type is mis ...
- 报错记录:getOutputStream() has already been called for this response
仅作记录:参考文章:http://www.blogjava.net/vickzhu/archive/2008/11/03/238337.html 报错信息: java.lang.IllegalStat ...
- 报错:org.hibernate.AssertionFailure: null id in com.tt.hibernate.entities.News entry (don't flush the Session after an exception occurs)
在使用hibernate创建数据库的表格时,出现了如下报错: 十二月 28, 2016 10:17:02 上午 org.hibernate.tool.hbm2ddl.SchemaExport perf ...
随机推荐
- HDU - 2612 Find a way(BFS搜索)
题目: 链接 思路: 用BFS分别以‘Y’和‘M’的位置为起点进行两次搜索,并把这两次的搜索结果在一个二维数组中保存下来,在对地图遍历遇到‘@’更行最小值. PS: 如果用‘Y’和‘M’点分别去搜每个 ...
- HDU1401 Solitaire
题目描述:8×8的棋盘上有4个棋子,棋子的运动方法如下:1.如果其上/下/左/右一格没有棋子,则可以去;2.如果其上/下/左/右一格有棋子,而且沿原方向再跳一步没有,则可以去. 给出初始结束位置,问8 ...
- RNNCell使用
目录 Recap input dim, hidden dim SimpleRNNCell Single layer RNN Cell Multi-Layers RNN RNN Layer Recap ...
- ppt_旋转抽奖_制作步骤
1 ppt制作抽奖转盘 插入饼状图,更改比例,更改颜色(一般选取相邻的一组颜色匹配比较好看): 插入竖文本框,编辑每一个部分为特等奖.一等奖.二等奖.三等奖: 全部选中,ctrl+G组合: 添加陀螺旋 ...
- Spring核心技术(八)——Spring自动装载的注解
本文针对自动装载的一些注解进行描述. 基于注解的容器配置 @Required注解 @Required注解需要应用到Bean的属性的setter方法上面,如下面的例子: public class Sim ...
- About SQL Server 2016 CPT2
SQL Server 2016 CTP2已经发布,可以从以下主页进行下载. http://www.microsoft.com/en-us/server-cloud/products/sql-serve ...
- 567. Permutation in String
Problem statement: Given two strings s1 and s2, write a function to return true if s2 contains the p ...
- 【状压+状态转移】A Famous Airport Managere
https://www.bnuoj.com/v3/problem_show.php?pid=25653 [题意] 给定一个3*3的九宫格,模拟一个停机坪.第一个格子一定是'*',代表take off ...
- codeforces 330b
#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 1100 int map[N]; ...
- PatentTips - Hierarchical RAID system including multiple RAIDs
BACKGROUND OF THE INVENTION The present invention relates to a storage system offering large capacit ...