未找到方法(FUNCTION_NOT_FOUND):request.contextPath

dandan9112 发布于 2016/03/22 16:59
阅读 430
收藏 0

【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”

@闲大赋 你好,想跟你请教个问题:

我的html中是这样写的:

<!DOCTYPE html>
<%
var path = request.contextPath();
var basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
var url = basePath + "ssl/loanConfirm.htm?loanId=";
print(path);
%>
<html>

但是浏览页面时却报错说没有contextPath这个方法~

加载中
0
闲大赋
闲大赋

java中,你可以通过request.getContextPath() 获取,在模板中,这种getter方法,可以通过属性名获取


var path = request.contextPath;
var schema = request.scheme;



你的代码里, request.contextPath () 表示调用一个注册名字为request.contextPath的方法名,所以会报错,没有找到方法request.contextPath


你可以在beetl中按照java习惯调用,但必须以@开头,比如

var path = @reqeust.getContextPath();




0
Say厮守永远
Say厮守永远
直接${ctxPath} 就能获得上下文url
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部