JavaWeb项目org.apache.jasper.JasperException: 解决方法


在做项目时候,遇到这个500错误。找了很久,jsp写法也没错误,在本地myeclipse可以运行,在别人的myeclipse不能运行,最后终于解决了,是tomcat的版本问题。

HTTP Status 500 -


type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /PCManage/controlsecletthenews.jsp(303,12) The function getNid must be used with a prefix when a default namespace is not specified
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
	org.apache.jasper.compiler.Validator$ValidateVisitor$1FVVisitor.visit(Validator.java:1506)
	org.apache.jasper.compiler.ELNode$Function.accept(ELNode.java:129)
	org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
	org.apache.jasper.compiler.ELNode$Visitor.visit(ELNode.java:242)
	org.apache.jasper.compiler.ELNode$Root.accept(ELNode.java:56)
	org.apache.jasper.compiler.ELNode$Nodes.visit(ELNode.java:200)
	org.apache.jasper.compiler.Validator$ValidateVisitor.validateFunctions(Validator.java:1531)
	org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1176)
	org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:846)
	org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
	org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:865)
	org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
	org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
	org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	serlvet.SearchNewsServlet.doPost(SearchNewsServlet.java:79)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.



原因;是tomcat6.0版本不够高,不支持以下代码这样下,因此不断报错。

解决方法:

(1)我是用tomcat6.0运行的,不断地提示错误代码,但是并没有错的。

报错代码贴出来,但是在我的myeclipse是可以运行:
 <table class="table table-hover" style="margin-top:10px;padding:20px;">
        
      <tr><td>新闻id</td><td>标题</td><td>类别</td><td>作者</td><td>浏览量</td><td>时间</td><td>照片路径</td><td>内容</td></tr>  
          <c:forEach items="${project_vector}" var="vector" varStatus="status">
        <tr>
        <td><c:out value="${vector.getNid()}"/></td>
        <td><c:out value="${vector.getNbiaoti()}"/></td>
        <td><c:out value="${vector.getNleixing()}"/></td>
        <td><c:out value="${vector.getNzuozhe()}"/></td>
        <td><c:out value="${vector.getNliulangliang()}"/></td>
        <td><c:out value="${vector.getNdate()}"/></td>
        <td><img style="height:30px;width:30px;background:blue" src="<%=request.getContextPath() %>${vector.getNphotepath()}" alt=""/></td><!-- <c:out value="${vector.getNphotepath()}"/> -->
        <td><c:out value="${vector.getNtext()}"/></td>
      
        </tr> 
      </c:forEach>   

(2)改用tomcat7.0,成功运行,完美解决了这个问题。

已标记关键词 清除标记
初学JavaEE碰到的问题,求大神帮帮忙 这是源代码 ``` <%@ page contentType="text/html;charset=gb2312" pageEncoding="utf-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <title>网上书店</title> <link href="css/bookstore.css" rel="stylesheet" type="text/css"/> </head> <body> <div class="head"> <div class="head_left"> <a href="#"> <img hspace="11" src="picture/logo_dear.gif" vspace="5"> </a> <br>      书店提供专业服务 </div> <div class="head_right"> <div class="head_right_nei"> <div class="head_top"> <div class="head_buy"> <strong> <a href="/bookstore/showCart.jsp"> <img height="15" src="picture/buy01.jpg" width="16"> 购物车 </a> </strong> | <a href="#">用户FAQ</a> </div> </div> <div class="head_middle"> <a class="title01" href="index.jsp"> <span>  首页  </span> </a> <s:if test = "session.user == null"> <a class="title01" href="login.jsp"> <span>  登陆  </span> </a> </s:if> <s:else> <a class="title01" href="logout.action"> <span>  注销  </span> </a> </s:else> <a class="title01" href="register.jsp"> <span>  注册  </span> </a> <a class="title01" href="#"> <span> 联系我们   </span> </a> <a class="title01" href="#"> <span> 网站地图   </span> </a> </div> <div class="head_bottom"> <form action="searchBook.action" method="post"> <input type="text" name="bookname" size="50" align="middle"/> <input type="image" name="submit" src="picture/search02.jpg" align="top" style="width: 48px; height: 22px"/> </form> </div> </div> </div> </div> </body> </html> ``` ![图片说明](https://img-ask.csdn.net/upload/201812/31/1546250296_572812.png)
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页