在线等:在servlet中使用getAttribute()时出错!!! 用request.getParameter试试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 req.getAttribute("msg")如果是空,就出错,改成s = req.getAttribute("msg"); String s = "";String s;试试还有 s = req.getAttribute("msg").toString(); s =(String)req.getAttribute("msg"); to nanman: msg不是空啊 我在jsp中写:session.setAttribute("msg","您好!");我现在改用:s =(String)req.getAttribute("msg");取回的值为null,不知为什么? 当然是空了。因为你在jsp中把数据封装到了session中,而在servlet中你却是从request中取,你说能成功吗?把s =(String)req.getAttribute("msg");改为:HttpSession session = req.getSession();s =(String)session.getAttribute("msg");就成了 求助!新创建的web工程里没有index.jsp文件,是神马情况? struts2配置出现:Action class [tutorial.HelloWorld] not found awstats 配置 遇到一个问题看看大神们有木有更好的办法 没JAVA基础学JSP有什么好资料。。 struts上传文件时,如何添加进度条? 这乱码应该如何解决啊!!~~急啊,,大家来看看..马上结贴 请教tomcat5.0.28 的配置问题~~~ 怎样设制按钮顺序? 求JAVAMAIL代码 java.net.URLEncoder.encode一般什么时候用到 请问使用什么方法能够知道查找到的数据库记录的个数?
s = req.getAttribute("msg");
String s;
试试
还有
s = req.getAttribute("msg").toString();
s =(String)req.getAttribute("msg");
我现在改用:s =(String)req.getAttribute("msg");
取回的值为null,不知为什么?
因为你在jsp中把数据封装到了session中,
而在servlet中你却是从request中取,你说能成功吗?把
s =(String)req.getAttribute("msg");
改为:
HttpSession session = req.getSession();
s =(String)session.getAttribute("msg");
就成了