作者PsMonkey (痞子军团团长)
站内java
标题Re: [JSP] 请教一下如何产生动态session变数,谢谢 …
时间Tue Jun 27 04:51:49 2006
==站内信件==
※ 引述《metalalive (瑞索弟的旋金世界)》之铭言:
: type Exception report
: message
: description The server encountered an internal error () that prevented it from fulfilling this request.
: exception
: org.apache.jasper.JasperException: Exception in JSP: /shopping-cart.jsp:14
: 11:
: 12: if( session.getAttribute(request.getParameter("goods_name")) == null ){
: 13: session.setAttribute( request.getParameter("goods_name") , Integer.parseInt( (String) request.getParameter("numbers")) );
^^^^^^^^^^^^^^^^
: 14: String tmpNum = (String) session.getAttribute(request.getParameter("goods_name"));
^^^^^^^^
: 15: //out.print((String) session.getAttribute("m1"));
: 16: }
: root cause
: java.lang.ClassCastException: java.lang.Integer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
提示仅到此为止
也请其他版友不要再给提示
如果还是不懂的话,去找 google: Auto-Boxing
然後搞懂 JSP 的隐函物件背後的真实物件是啥
还有 API 要怎麽看...
光看到 (String) request.getParameter() 这行
就可以想像,原 po 应该是只看范例没搞懂细节就硬上...
=====
以下是对所有观看 Java 版的版友们说:
请不要把 Java 版(或是任何一个程设讨论版)
当作超强人工智慧 debug 器
写程式到现在,虽然没写过什麽豪华程式,不过也写了不少
除了 syntax error 之外
我还没遇到 bug,是 Error Message 没有提示清楚的
虽然 JSP 上的 erroe message 会夹带一卡车有的没的 class 丢出来的 msg
但是,一则看各段 message 最顶端的那一行
再者,就是挑彷佛常常看到的 class,然後去切 class name
通常一切就说明清楚了
如果这样子还不行,那就一定表示基本概念还不够
是不用严重到砍掉重练,或是得回头翻 TIJ 还是一些基础书籍
有时候瞎子摸象的方法也是一种很好的学习方式(短期效益不高就是了)
但是,请不要到这里找明眼人帮你带路
那还不如回头翻 TIJ
有讲错请狠批... [摆茶点]
--
侃侃长论鲜窒碍 网站:
http://www.psmonkey.idv.tw
众目睽睽无心颤 个人版:telnet://legend.twbbs.org
茕居少聊常人事
杀头容易告白难 欢迎参观 Java 版(@ptt.cc) \囧/
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.204.16.17