我在messagelist.jsp页面是这样获取的,运行时报错,请问应该怎么该啊?
<%
String num=new String(request.getSession().getAttribute("num").toString());
System.out.println(num);
if(num==null)
{
window.location="viewMessage.do";
}
else if(num.equals("0"))
{
out.print("<script>alert('复选框没有被选中!');</script>");
}
else
{
out.print("<script>alert('删除成功!');</script>");
}
%>Exception:严重: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: ServletException in '/pages/messagelist.jsp': Unable to compile class for JSPAn error occurred at line: 18 in the jsp file: /pages/messagelist.jsp
Generated servlet error:
window.location cannot be resolved to a type
<%
String num=new String(request.getSession().getAttribute("num").toString());
System.out.println(num);
if(num==null)
{
window.location="viewMessage.do";
}
else if(num.equals("0"))
{
out.print("<script>alert('复选框没有被选中!');</script>");
}
else
{
out.print("<script>alert('删除成功!');</script>");
}
%>Exception:严重: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: ServletException in '/pages/messagelist.jsp': Unable to compile class for JSPAn error occurred at line: 18 in the jsp file: /pages/messagelist.jsp
Generated servlet error:
window.location cannot be resolved to a type
解决方案 »
- 【100分】做一个在线视频网站,问一些问题
- 网页上画几何图形
- 如何用流获取文本框值:急!!
- 中文不能在facelets的xhtml的script中正常输出,中文显示#1213;#1322;之类的东西
- portlet的jsp中的renderRequest cannot be solved问题
- 浏览器在发送信息时,使用了base64标准干了些什么事情啊?
- DWRUtil.addRows 使用时 提示对象不支持此属性或方法
- 如何用main模拟上传文件的jsp?
- SmartUpload上传提示这样的错误cannot access upload.SmartUpload?
- 关于部署在weblogic中的项目用IE访问页面加载慢但是用火狐或者谷歌浏览器访问很快的问题,求大神指点
- 如何连接到内网的tomcat
- thickbox中如何显示嵌套的问题
这个错是说你 调用了未知的 类
window.location="viewMessage.do"; 应该改为
window.location.href ="viewMessage.do";
out.print(" <script> window.location.href = \"viewMessage.do\"; </script> ");
String num=new String(request.getSession().getAttribute("num").toString()); 首先你要确定request.getSession().getAttribute("num") 不为 NULL,
其次 假如它不为NULL,那么它的toString(),已经是得到它的String形式的值了,搞不明白为什么还有去
new String (....)顺便对 4楼的 朋友说一声,lz的那个out.print(.....)也是对的,别人里面用的是 单引号,你没有看清楚吧?
org.apache.jasper.JasperException
<%
String num = null;
if (request.getSession().getAttribute("num") != null) {
num = request.getSession().getAttribute("num").toString();
System.out.println(num);
}
if (num == null) {
out.print(" <script> window.location.href = \"viewMessage.do\"; </script> ");
}
else if (num.equals("0")) {
out.print(" <script> alert('复选框没有被选中!'); </script> ");
}
else {
out.print(" <script> alert('删除成功!'); </script> ");
}
%>