美文网首页
设置、查看context root(项目根路径)的方法与getC

设置、查看context root(项目根路径)的方法与getC

作者: hw_zhu | 来源:发表于2017-02-22 14:45 被阅读333次
项目根路径解释:

即../项目名;如 我的工程名是ParkRecord 则我的根路径是 /ParkRecord。
用途: 常用语jsp 中获取绝对路径来找寻资源


  • 一、设置方法
    1、鼠标选中工程,右键选择“properties”---选择“Web Project Settings”---在context root 填写 项目的名字
    2、鼠标选中工程,
    alt+enter 快捷方式
    进入“properties”--选择“Web Project Settings”---在context root 填写 项目的名字

  • 二、获取方法
    1、alert(<%=request.getContextPath()%>);显示

<head>
<script type="text/javascript">
function display_alert()
  {
  alert(<%=request.getContextPath()%>);
  }
</script>
...
<center>
                <input value="跑起来"  name="btnK" type="submit"/>
                <input value="导出来"  name="btnK" type="button"
                onclick="display_alert()"/>
           </center>

相关文章

网友评论

      本文标题:设置、查看context root(项目根路径)的方法与getC

      本文链接:https://www.haomeiwen.com/subject/pqhmwttx.html