jsp里的变量

来源:互联网 发布:org.json jar包 编辑:程序博客网 时间:2024/05/02 07:17
1、basePath
<%                                                                                                                                                                                                               //假设我有个项目drp
    String path = request.getContextPath();                                                                                                                                           //相当于访问项目路径中的/drp        
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";            //相当于http://localhost:8080/drp/
%>
<html>
    <head>
        <base href="<%=basePath %>">                //相当于项目中的所有路径的起始位置都是http://localhost:8080/drp/,即都是从根路径开始,此时所有相对路径都失去意义。
        <meta http-equiv="Content-Type" content="text/html; charset=GB18030">
        <title>添加分销商</title>
        <link rel="stylesheet" href="style/drp.css">                            //此时的href相当于:http://localhost:8080/drp/style/drp.css
        <script src="script/client_validate.js"></script>                    //此时的src相当于:http://localhost:8080/drp/script/client_validate.js
        <script type="text/javascript">

2、request.getParameter   
jsp里的java文件中可以通过request.getParameter("id")得到刚页面刚输入的文本内容