Invalid character found in the request target [/expert/deleteExpert?idList[]=10&idList[]=11].

做练习时,遇到个错误,记一下

问题

java.lang.IllegalArgumentException: Invalid character found in the request target [/expert/deleteExpert?idList[]=10&idList[]=11]. The valid characters are defined in RFC 7230 and RFC 3986
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:490) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.41.jar:9.0.41]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888) [tomcat-embed-core-9.0.41.jar:9.0.41]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597) [tomcat-embed-core-9.0.41.jar:9.0.41]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.41.jar:9.0.41]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_111]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_111]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.41.jar:9.0.41]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_111]

错误做法

controller里

 @RequestMapping(value = "/deleteExpert",method = RequestMethod.DELETE)
    public void deleteExpert(@RequestParam("idList") List<Integer> idList){
        expertService.deleteExpert(idList);
    }

前端vue

delExpert: { url: '/expert/deleteExpert', method: 'delete' },

错误页面
在这里插入图片描述

改正之后

controller 把 RequestParam 改成 PathVariable

@RequestMapping(value = "/deleteExpert/{idList}",method = RequestMethod.DELETE)
    public void deleteExpert(@PathVariable("idList") List<Integer> idList){
        expertService.deleteExpert(idList);
    }

前端

delExpert: { url: '/expert/deleteExpert/:idList', method: 'delete' }

路径正确,删除成功
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值