jsp中怎么有这种错误,The method getContextPath() is undefined for the type ServletContext
明明就有这个方法啊,org.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurre...
明明就有这个方法啊,
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 4 in the jsp file: /MyJsp.jsp
The method getContextPath() is undefined for the type ServletContext
1: <%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2: <%
3: //String path = request.getContextPath();
4: String path = config.getServletContext().getContextPath();
5: out.println(path);
6: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
7: %> 展开
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 4 in the jsp file: /MyJsp.jsp
The method getContextPath() is undefined for the type ServletContext
1: <%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
2: <%
3: //String path = request.getContextPath();
4: String path = config.getServletContext().getContextPath();
5: out.println(path);
6: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
7: %> 展开
展开全部
注意你引的包的版本,低版本的就没有此方法。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
getContextPath()
方法未定义错误吗!
undefined for the type ServletContext
方法未定义错误吗!
undefined for the type ServletContext
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询