1. 程式人生 > >encodeURIComponent傳入後臺解碼

encodeURIComponent傳入後臺解碼

<script>
$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
			   rules:{
			     code:{
			      required:true,
			      rangelength:[5,10],
			      remote:"${ctx}/sierac/product/check?oldcode=" + encodeURIComponent('${product.code}') //此處傳入後臺
			     },

			     name:{
			       required:true,
			      rangelength:[1,10]
			     },
			     shelfLife:{
			     required:true,
			     digits:true
			     },
			     pcsPerCtn:{
			      required:true,
			     digits:true
			     }
			   },
			   messages:{
			    code:{
			      required:"產品編碼不能為空",
			      rangelength:"編碼長度在5-10之間",
			      remote:"該產品編碼已經存在,請重新輸入"
			    },
			   
			    name:{
			       required:"產品名稱不能為空",
			       rangelength:"產品名稱長度介於1-10之間"
			    },
			    shelfLife:{
			     required:"保質期不能為空",
			     digits:"必須為整數"
			    },
			    pcsPerCtn:{
			    required:"每箱單品數不能為空",
			     digits:"單品數必須為整數"
			    }
			   },
				submitHandler: function(form){
					loading('正在提交,請稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("輸入有誤,請先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});

		});
	</script>
<form:form id="inputForm" modelAttribute="product" action="${ctx}/sierac/product/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label" id="code">產品程式碼:</label>
			<div class="controls">
				 <c:choose>
                                        <c:when test="${empty product.id}">
                                                <form:input path="code" htmlEscape="false" maxlength="255"
                                                        class="input-xlarge" />
                                        </c:when>
                                        <c:otherwise>
                                                <form:input path="code" htmlEscape="false" maxlength="255"
                                                        class="input-xlarge" readonly="true" />
                                        </c:otherwise>
                                </c:choose>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>

後臺:

 @ResponseBody
    @RequiresPermissions("sierac:product:edit")
    @RequestMapping(value = "check")
    public String check(HttpServletRequest request ,String oldcode, String code) throws UnsupportedEncodingException {
        String s = new String(request.getParameter("code").getBytes("ISO8859-1"), "UTF-8");//encodeURIComponent編碼轉換
        if (s !=null && s.equals(oldcode)) {
			return "true";//不重複
		} else if (s !=null && productService.findByCode(s)==null) {
			return "true"; //不重複
		}
		return "false"; //重複
	}



相關推薦

encodeURIComponent傳入後臺解碼

<script> $(document).ready(function() { $("#name").focus(); $("#inputForm").validate({

後臺使用jeecg模板excel匯出,會出現檢索欄位傳入後臺亂碼的問題

後臺使用jeecg模板excel匯出,會出現檢索欄位傳入後臺亂碼的問題。 解決方案: 針對亂碼欄位進行轉碼,例new String(orgNameUrlStr.getBytes("iso8859-1"),"UTF-8") 參考程式碼: String orgNameUrlS

java 前臺傳入後臺亂碼

有多種解決方案 1.String strUTF8 = new String(contractNo.getBytes("ISO8859-1"),"UTF-8"); 2.使用form表達post提交,提交的引數為contractNo 3.如果是get方式提交,提交的引數

前臺如何將json格式的字串傳入後臺

1、前臺javascript程式碼: $.fn.serializeObject = function() { var o = {}; var a = this.se

前端JSON傳入後臺解析

data =[{optionId:"1",topicId:"2"},{optionId:"2",topicId:"3"},{optionId:"3",topicId:"4"}] @ResponseBody @RequestMapping(value = "/isV

【s:checkboxlist】JS中取s:checkboxlist選中的value傳入後臺例項

body中: <td width="35%">      <s:checkboxlist name="cc" id="kscc1" list="#{'AM':'上午','PM':'下午' }" value="" cssStyle="width:20px;

前端進行圖片壓縮並傳入後臺

客戶端:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>vue-demo</title>

json傳入後臺物件為空

前端程式碼: var cmopSmsExt={list:[]}; function onAfterEdit(rowIndex, rowData,changes){ if(changeBefore!

js前臺編碼,java後臺解碼,el表示式拼裝param中文引數編碼

js前臺編碼: 1.使用兩次encode function query(nameObj,brandnameObj){   var namevalue = window.encodeURI(window.encodeURI(nameObj.value));   var bra

encodeURIComponent編碼後java後臺解碼

scrip 特殊 one asc OS code post utf 後臺 encodeURI不會對#等特殊符號編碼,當訪問地址中含有#等特殊字符的時候,會自動刪除#後面的字符串,導致頁面有誤; 解決辦法:使用encodeURIComponent編碼; JavaScript

JS中用encodeURIComponent編碼,後臺JAVA怎麼解碼

JS中用encodeURIComponent編碼兩次 var p = {}; p.Map = [{f : 'customNo', t : '客戶編號'},{f : 'customName', t : '客戶名稱'}]; var param = JSON.stringify(p); var u

escape()、encodeURI()、encodeURIComponent() 編碼解碼

escape 輸出 one body 說明 簡單 跳轉 blog 部分 1 escape()、encodeURI()、encodeURIComponent()區別詳解 2 3 JavaScript中有三個可以對字符串編碼的函數,分別是: escape,enc

thymeleaf javascript取後臺傳入的數值

log mes ole line inline nbsp java pan div <script th:inline="javascript"> /*<![CDATA[*/ var message = [[${message}]]

前臺傳入base64格式圖片上傳,java後臺轉為MultipartFile

前臺傳入base64格式圖片上傳,java後臺轉為MultipartFile 之前一直用MultipartFile去接收檔案上傳的資料,但是今天接觸到app開發,前端from-data裡邊傳的是base64格式的值,在這裡做點小筆記,demo 以供參考: 程式設計師之間的交流做好

Go後臺對圖片base64解碼,並儲存至檔案伺服器。

單人開發移動端專案前後端,對專案中出現的一些問題做記錄。 前端使用vue,預設base64編碼上傳圖片,略過。 後臺使用go-gin框架,主要使用了路由和資料傳輸和繫結的功能 1. 後端宣告一個結構體用於接收前端資料和將資料儲存到資料庫(mangodb) 其中ImgList用於接收

ssm專案後臺向前臺傳入list資料

增加將MySQL資料庫中的資料,使用list取出,並傳入jsp直接使用 xml檔案: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.or

前臺如何將多個json物件傳入java後臺(轉)

前臺json格式的資料如何傳入後臺 1. 將要傳入後臺的資料組裝成JSON格式的字串: var jsonStr = [{'name':'jim' , 'age':20} , {'name':'king' , 'age':26},{'name':'jge' , 'age':

前臺js傳入json或map型別資料給後臺後臺接收處理操作

5.java後端使用request拿到json資料String ds = request.getParameter("postData");JSONArray json=JSONArray.fromObject(ds); //使用net.sf.json.JSONObject物件來解析jsonJSONObjec

將前臺json物件傳入java後臺

前臺json格式的資料如何傳入後臺 1. 將要傳入後臺的資料組裝成JSON格式的字串: var jsonStr = [{'name':'jim' , 'age':20} , {'name':'king' , 'age':26},{'name':'jge' , 'age':

用js將後臺傳入的json資料放在前臺顯示

{"idCardAddress":"123","idCardNumber":"345","eRegAddress":"456"} 後臺傳過來的資料是這樣的,前臺無法通過el表示式直接獲取,通過 js