jsp的问题

natato 2008-08-28 10:24:09
if (request.getAttribute("photoshu")!=null){

int photoshu = ((Integer) request.getAttribute("photoshu")).intValue();


}

<%=photoshu%>应用时报错,怎么解决谢谢
...全文
86 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xzjbeduhs1983 2008-09-03
  • 打赏
  • 举报
回复
<c:if test="${requestScope.photoshu!=null}">
${requestScope.photoshu}
</c:if>
ace112212 2008-09-03
  • 打赏
  • 举报
回复
当 photoshu==null

时就要抛空值针啦
lazy122061517 2008-08-28
  • 打赏
  • 举报
回复
变量没有初始化
<%! int photoshu=0; %>
<%
if (request.getAttribute("photoshu")!=null){

photoshu = ((Integer) request.getAttribute("photoshu")).intValue();


}
%>

<%=photoshu%>
hanbb 2008-08-28
  • 打赏
  • 举报
回复
错误贴出来
natato 2008-08-28
  • 打赏
  • 举报
回复
报这个错the local variable photo may not have been initialized
natato 2008-08-28
  • 打赏
  • 举报
回复
这样还不行
还是报错
natato 2008-08-28
  • 打赏
  • 举报
回复
这样还不行
还是报错
hanbb 2008-08-28
  • 打赏
  • 举报
回复
int photoshu=0 ;
if (request.getAttribute("photoshu")!=null){

photoshu = ((Integer) request.getAttribute("photoshu")).intValue();


}

<%=photoshu%>
ruanguanfei 2008-08-28
  • 打赏
  • 举报
回复
先定义变量photoshu

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧