<% request.setCharacterEncoding("utf-8"); request.setAttribute("path",request.getContextPath()); request.setAttribute("cssVersion",1); request.setAttribute("jsVersion",6); //要用到js地方使用 通过版本保证更新 <script type="text/javascript" src="${path}/js/reim/expense.js?${jsVersion}"></script> request.setAttribute("title","GIP"); request.setAttribute("vEnter", "\n"); request.setAttribute("USER_TYPE_ADMIN", 99); request.setAttribute("USER_TYPE_MARKET_MANAGER", 20); request.setAttribute("USER_TYPE_MARKET", 22); request.setAttribute("USER_TYPE_PARTNER", 9); %>
2.提交表单之前验证某些选项方法
<form class="form-horizontal" action="${path}/reim/submitTask.d" onsubmit="return checkForm();" method="POST"> <input type="hidden" name="type" value="2"> <input type="hidden" name="taskId" value="${taskId}"> <input class="btn blue" type="submit" name="outcome"> </form> //通过点击事件方法进行验证 <script> function checkForm(){ var comment = $('#comment').val(); if(comment == ''){ alert('请输入备注说明!'); return false; } return true; } </script>
后台传给前台的方法
String rulemodeid=req.getParameter("rulemodeid");
req.setAttribute("rulemodeid", rulemodeid);
前台js的方法
var rulemodeid= "${rulemodeid }";
其中“”是必须加的,不然报defined错
checkbo根据后台参数选中
<div class="layui-input-block" required lay-verify="required"> <input type="checkbox" name="size" title="XS" value="XS" > <input type="checkbox" name="size" title="S" value="S"> <input type="checkbox" name="size" title="M" value="M"> <input type="checkbox" name="size" title="L" value="L"> <input type="checkbox" name="size" title="XL" value="XL"> <input type="checkbox" name="size" title="XXL" value="XXL"> <input type="checkbox" name="size" title="XXXL" value="XXXL"> </div> <script> var str= "${size}"; $(str.split(",")).each(function (i,e){ $("input[name='size'][value='"+e+"']").prop("checked",true); }); </script>