如何獲取js中url後面的引數
阿新 • • 發佈:2019-01-22
<script type="text/javascript">
function refuse() {
window.location.href= '${ctx}/${optionUrlString}/delete/' + id + "?" + refuseReason;
}
</script>
@RequestMapping (value = "/leaderView/delete/{purchaseDetailId}", method = RequestMethod.GET)
public String leaderRefuse (@PathVariable("purchaseDetailId") Integer purchaseDetailId, RedirectAttributes redirectAttributes, HttpServletRequest request){
PurchaseDetail purchaseDetail = purchaseDetailService.findOne(purchaseDetailId);
PurchaseApply purchaseApply = purchaseDetail.getPurchaseApply();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
if (!PurchaseApply.STATUS_NEW.equals(purchaseApply.getStatus())) {
if (!PurchaseApply.STATUS_PURCHASE.equals(purchaseApply.getStatus())) {
purchaseDetail.setDetailState(UserUtils.getCurrentUser().getPerson().getName() + "(" + sdf.format(DateUtils.getCurrentDate()) + "): 拒絕採購!");
} else {
purchaseDetail.setDetailState(UserUtils.getCurrentUser().getPerson().getName() + "(" + sdf.format(DateUtils.getCurrentDate()) + "): 無貨!");
}
String refuseReason = request.getQueryString();//獲取url中引數的值
try {
refuseReason = URLDecoder.decode(refuseReason,"UTF-8"); //將從url中獲得的引數的值進行轉碼
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println("拒絕原因:" + refuseReason);
}
}