vueバックグラウンドへのパラメータ伝達の問題
2113 ワード
2019-35-18 11:35:43:890[http-nio-8081-exec-10]WARN o.s.w.s.m.support.DefaultHandlerExceptionResolver-Resolved exception caused by Handler execution: org.springframework.web.bind.MissingServiceletRequestParameterException:Required String parameter'pName'is not present vueに接触したばかりのおつまみ鶏として、多くのinputクエリ時にgetメソッドでバックグラウンドにアクセスする際に発生する問題の1つです.
こちらがフロントの方法です
これはバックグラウンドメソッドのエラーの原因です.あるinputの値が空で、pNameが空で、変更する必要があります.
彼がデータを持っていない時p 2はundefinedでそれから楽屋は判断に参加します
これで1つまたは複数のinputを空にすることができます
vueに触れたばかりなので、何か間違っていることがあるかもしれません.助けてほしいです.ありがとうございます.
findlists() {
let p1 = this.formInline.pCate ||undefined
let p2 = this.formInline.pName.join||undefined
let p3 = this.formInline.pPrice|undefined
let p4 = this.formInline.pJianjie||undefined
console.log(p2)
console.log(p1)
console.log(p3)
console.log(p4)
axios({
url:'http://localhost:8081/product/searchnumcha',
method:'get',
params:{
pCate:p1,
pName:p2,
pPrice:p3,
pJianjie: p4,
},
}).then(({data})=>{
this.allpro = data;
console.log(this.tabledatel.pCate)
}
)
},
こちらがフロントの方法です
@RequestMapping("/searchnumcha")
public int searchnumcha(@RequestParam(value = "pCate" ) String cate,@RequestParam(value = "pName") String name,
@RequestParam(value = "pPrice") String price,@RequestParam(value = "pJianjie") String info){
return productService.searchnumcha(cate,name,price,info);
}
これはバックグラウンドメソッドのエラーの原因です.あるinputの値が空で、pNameが空で、変更する必要があります.
let p2 = this.formInline.pName.join+''||undefined
彼がデータを持っていない時p 2はundefinedでそれから楽屋は判断に参加します
if(name.equals("undefined")){
name = null;
}
これで1つまたは複数のinputを空にすることができます
vueに触れたばかりなので、何か間違っていることがあるかもしれません.助けてほしいです.ありがとうございます.