html jsp 获取后端传过来的参数值 [[${starttime}]]

效果图:

在这里插入图片描述

1,后端代码


    @RequestMapping("/bzenterpage")
    public String bzenter(Model model){
    
		  Date date=new Date();
          String endtime=DateUtil.formatFromDate(DateUtil.YYYY_MM_DD_HH_MM_SS,date);
          Calendar calendar = Calendar.getInstance();
          calendar.setTime(date);
          calendar.add(Calendar.MONTH, -1);//当前时间前去一个月,即一个月前的时间
          String starttime=DateUtil.formatFromDate(DateUtil.YYYY_MM_DD_HH_MM_SS,calendar.getTime());
          
          model.addAttribute("starttime",starttime);
          model.addAttribute("endtime",endtime);
          
          return "thymeleaf/bzenter.html"; //传到html页面去
          
		  return "thymeleaf/bzenter"; 	//传到jsp页面去
    }

2,html页面接收参数

格式:’[[${**}]]'


  <input type="text" id="cystartdate" style="width: 130px;height: 25px;margin-left: 10px;"  /> -
  <input type="text" id="cyenddate"   style="width: 130px;height: 25px"  />
  <button class="reloadBtn" onclick="cyksrefresh()">刷新<img class="reloadImg" src="/static/img/reload.png" alt=""></button>

   var starttime = '[[${starttime}]]';
   var endtime='[[${endtime}]]';

   $('#cystartdate').val(starttime);
   $('#cyenddate').val(endtime);



   layui.use(['form','table'], function() {
        layui.laydate.render({
            elem: '#cystartdate',
            type:'datetime' ,trigger: 'click'
        });
        layui.laydate.render({
            elem: '#cyenddate',
            type:'datetime' ,trigger: 'click'
        });
   });
   
    

3,jsp页面接收参数

格式:’${**}'


 <input type="text" id="cystartdate" style="width: 130px;height: 25px;margin-left: 10px;" value="${starttime}" /> -
 <input type="text" id="cyenddate"   style="width: 130px;height: 25px" value="${endtime}" />
 <button class="reloadBtn" onclick="cyksrefresh()">刷新<img class="reloadImg" src="/static/img/reload.png" alt=""></button>

  var starttime='${starttime}';
  var endtime='${endtime}';


 layui.use(['form','table'], function() {
        $('#cystartdate').val(starttime);
        $('#cyenddate').val(endtime);
        
        layui.laydate.render({
            elem: '#cystartdate',
            type:'datetime' ,trigger: 'click'
        });
        layui.laydate.render({
            elem: '#cyenddate',
            type:'datetime' ,trigger: 'click'
        });
   });
   

你可能感兴趣的:(html,JavaScript,javascript,ajax,html)