一、项目中应用:
1.PrivInterceptor.java 权限拦截密码过于简单直接跳转至修改密码jsp,且传上次访问的路径requestUrl。
/** * 二、登录成功后,根据URL进行权限判断 */ HttpServletRequest request = ServletActionContext.getRequest(); String currentURL = request.getRequestURI(); if( !"".equals(bussiness_id.trim()) && null!=bussiness_id ) { /** * 2.1判断工号登录后,业务密码是否为123456,是跳转到商户安全设置,修改业务密码 */ TBussinessSafe busSafe = bussiSafeDAO.selectByPrimaryKey(bussiness_id); if( null!=busSafe ) { String MD5password = KeyedDigestMD5.getKeyedDigest("123456","").toUpperCase();//获得123456的MD5值 String bussinessPass2 = busSafe.getBussinessPass2();//获得工号业务密码 if( MD5password.equals(bussinessPass2) ) { String requestUrl = currentURL+(request.getQueryString()==null?"":"?"+request.getQueryString()); act.put("requestUrl", requestUrl);//本次请求的Url act.put("message", "首次登录请设置您的“业务密码”,业务密码将用于保护您的相关资金操作。"); return "updateBussinessPassword"; } }
?2.js调用上次你请求的URL,实现修改完密码后,自动跳转到上一次访问的路径
function doUpdateSave(){ $('#updateForm').dialogSubmit(doValidate(),'SafeManager_motifyPass',null,sussCallBack); } function sussCallBack(data,win){ switch(data){ case '3001': $.hpDialog.alert(errorMessage[data]) ; break case '3002': $.hpDialog.alert(errorMessage[data]) ; $(win.document).find('input[type="password"]').val(''); $(win.document).find('.qr1').html(''); $(win.document).find('#safe\\.newpassErr').removeData('newstate'); var requestUrl = $(win.document).find('#requestUrl'); if(requestUrl){ var from = requestUrl.val(); if(from)win.location.href=from; } break case '3006': $.hpDialog.alert(errorMessage[data]) ; break default: $.hpDialog.alert(errorMessage[data],function(){$.dialog.close();}) ; } }
?3.jsp页面
<%@ include file="/cssBasePage.jsp"%> <script type="text/javascript" src="<%=path%>/jsp/phone/business/safe/passMotify.js"></script> <script type="text/javascript"> </script> </head> <body> <form id="updateForm" name="updateForm"> <input type="hidden" id="initLoadMethod" name="initLoadMethod" value="initsale" /> <input type="hidden" id="requestUrl" name="requestUrl" value="${requestUrl }" /> <div class="cftbox"> <hp:HpNavigate2 hasOperation="true">商户安全设置</hp:HpNavigate2> <div class="xgqh"> <s:if test="message!=''"> <s:property value="message"/> </s:if> </div> <ul> <li><div id="newpasstitle" class="tm">新交易密码:</div><div class="sr"><hp:HpInputPass name="safe.bussinessPass2" id="safe.bussinessPass2" TClass="srinput" TOnBlur="javascript:onBlurValiNewPass(this.value,'safe\\\\.newpassErr')"></hp:HpInputPass></div><div id="safe.newpassErr" class="qr1"></div></li> <li><div id="surepasstitle" class="tm">提交新密码:</div><div class="sr"><hp:HpInputPass name="safe.state" id="safe.state" TClass="srinput" TOnBlur="javascript:onBlurValiSurePass(this.value,'safe\\\\.surepassErr')"></hp:HpInputPass></div><div id="safe.surepassErr" class="qr1"></div></li> <li><div class="tm"></div><div class="sr"><hp:HpButton TJsClick="javascript:doUpdateSave()" TValue="save" id=""></hp:HpButton><hp:HpButton TJsClick="javascript:doReset()" TValue="reset" id=""></hp:HpButton></div></li> </ul> <div style="clear:both"></div> </div> </form> </body> </html>?
?
二、jsp引用文件的两种方式:
?
1.在jsp中我们引入文件一般形式为这样:
<script type="text/javascript" src="<%=path %>/jsp/phone/notice/noticeList.js"></script><!--绝对路径-->
<script type="text/javascript" src="jsp/phone/notice/noticeList.js"></script><!--相对路径-->
可以看出jsp默认的访问路径可以直接使用相对路径,因为jsp头部已经引用了<base href="<%=basePath%>"/>
?
2.path和basePath,我的java工程为b2cPlatform,所以:
<%=path%>:/b2cPlatform
<%=basePath%>:http://localhost:8082/b2cPlatform/
?
三、js的window.location.href的两种访问方式:
###根据jsp默认的访问路径,js在调用时候可以分:绝对路径、相对路径。
?
1.我的代码
<script type="text/javascript"> function test(){ window.location.href='HelpInfo_queryHelpInfoList?initMethod=iquery'; //window.location.href= '/b2cPlatform/HelpInfo_queryHelpInfoList?initMethod=iquery'; } </script> </head> <body> <div> <input type="button" onclick="test()" value="testaaaaaa"/></div> </body> </html>
? ##以上window.location.href的两种访问方式都正确!!!
?
?
四、<a href="">的两种访问方式:
1.绝对路径: <a href="/b2cPlatform/HelpInfo_queryHelpInfoList?initLoadMethod=iquery">testbbbbb</a> 2.相对路径: <a href="HelpInfo_queryHelpInfoList?initLoadMethod=iquery">testbbbbb</a>
##以上<a href="">的两种访问方式都正确!!!
?
?
?
?