ajax POST注意事項
1606 ワード
ajax通信を使用してデータアレイを転送する場合、正しいフォーマットでデータを送信する場合がありますが、BackEnd側ではこのデータを読み込めない現象があります.
var dataSet = {
"userName" : userName,
"userID" : userID,
"userPassword" : userPassword,
"userDepartment" : userDepartment,
"userNum" : userNum
};
$.ajax({
url: "/updateRow",
method:"POST",
data: dataSet,
traditional : true,
success: function(response){
console.log(response);
},
error : function(error){
console.log(error);
}
});
たとえば、これらのスクリプトにデータを送信します.@ResponseBody
@RequestMapping(value = "/updateRow", method = RequestMethod.POST )
public String updateRow(@RequestParam(value="userName") String[] user_name,
@RequestParam(value="userID") String[] user_ID,
@RequestParam(value="userPassword") String[] Password,
@RequestParam(value="userDepartment") String[] Department,
@RequestParam(value="userNum") String[] userNum ) throws Exception
{
Map param = new HashMap();
for(int i=0;i<user_name.length;i++)
{
param.clear();
param.put("userName",user_name[i]);
param.put("userID",user_ID[i]);
param.put("userPassword",Password[i]);
param.put("userDepartment",Department[i]);
param.put("userNum",userNum[i]);
oracle.selectOne("com.nanum.mes.service.dao.BoardDAO.updateRow",param);
}
return "Success";
}
コントローラでデータを受信するとajaxモジュールに従来のオプションがない場合、データの読み取りが全くできない現象が発生します...配列からパラメータを受信する場合は、従来の:trueを設定します.(この操作を行わないと配列を読み込めません)Reference
この問題について(ajax POST注意事項), 我々は、より多くの情報をここで見つけました https://velog.io/@kiwon1000/ajax-POST-시-주의사항テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol