标题:java.lang.NumberFormatException: null 错误
取消只看楼主
fanxiao46
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-6-27
结帖率:0
已结贴  问题点数:10 回复次数:1 
java.lang.NumberFormatException: null 错误
我是根据书上写的代码,启动Tomcat后,输入的是网址是http://localhost:8080/Test/servlet/CounterServlet
网页上出现结果了,可是MyEclipse报错了,有哪位高手指点一下不胜感激。
java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at TestOne.CounterServlet.init(CounterServlet.java:36)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    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:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.(JIoEndpoint.java:489)
    at java.lang.Thread.run(Unknown Source)

MyEclipse中的代码:
public class CounterServlet extends HttpServlet {
    int counter = 0;// 设点击数是0
    int org = 5;// 设初始的配置的点击数值是5

    @Override
    /**
     * 处理doGet请求
     */
    protected void doGet(HttpServletRequest req, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=gb2312");// 设置编码格式
        PrintWriter out = response.getWriter();
        counter++;
        out.print("自从这个Servlet载入,它已经被访问了" + counter + "次,加上初始的配置,"
                + "这个Servlet共被访问了" + (org + counter) + "次");
    }

    /**
     * 初始化方法,获得初始化参数
     */
    @Override
    public void init() throws ServletException {
        String c = getInitParameter("conter");
        try {
            org = Integer.parseInt(c);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
搜索更多相关主题的帖子: java lang null 
2010-06-27 13:24
fanxiao46
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-6-27
得分:0 
,感谢各位的帮助。我是根据《JSP应用开发详解(第三版)》P131写的,可是在书上我没有发现让我配置Servlet呀,各位有什么好的jsp书籍给我推荐一下,我这里不胜感激,谢谢
2010-07-08 07:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-311388-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.198902 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved