Project scenario:
Due to environmental problems, the server is only allowed to use the post and get methods to call the interface. The delete interface written using the post method can be called locally, but an error is reported in the server.
Problem description
Use the post method for logical deletion and error reporting, and use @pathvariable
to obtain the front-end transmission parameters:
@PostMapping("/delete/{userGroupIds}")
public ResponseBean<Object> deleteUserGroup(@PathVariable("userGroupIds") String userGroupIds){
return userGroupService.deleteUserGroup(userGroupIds);
}
When using postman to call the server interface, the following error messages appear:
The front-end page calls the interface and reports the following error, cross domain:
Cause analysis:
The post method needs to use @Rquestbody
to obtain parameters. This problem occurs when null is passed. The specific details were not clarified.
Solution:
Change the @pathvariable
method to @rquestbody
.
@PostMapping("/delete")
public ResponseBean<Object> deleteUserGroup(@RequestBody UserGroupIdDTO userGroupIds){
return userGroupService.deleteUserGroup(userGroupIds);
}
The parameters in UserGroupIdDTO are as follows:
@Data
public class UserGroupIdDTO {
private String userGroupId;
}
Read More:
- [Solved] “status“:405,“error“ Request method ‘POST‘ not supported“
- Redis Startup Error: Creating Server TCP listening socket 127.0.0.1:6379: bind: No error
- [Solved] Redis Error: Error condition on socket for SYNC: No route to host
- Java Web uses AJAX POST Method 405 terror [Solved]
- Microservice call exceptions: error feign.RetryableException: Read timed out executing POST http://xxx…….
- [Solved] spingboot Error: I/O error on POST request for “9411/api/v2/spans“: connect timed out
- [Tomcat] Unrecognized Windows Sockets error: 10106: Socket creation failed
- [Solved] Windows Redis Error: Could not create server TCP listening socket 127.0.0.1:6379: bind…
- Java.sql.sqlexception: unable to read more data from socket
- [Solved] socket failed: EPERM (Operation not permitted)
- java.net.SocketException: software caused connection abort: socket write error resolution (selenium)
- How to Solve JasperFillManager.fillReport Stuck issue (No Error and No Processing)
- [Solved] Python Error: socket.error [Errno 9] Bad file descriptor
- [Solved] canal Startup Error: error while reading from client socket java.io.IOException: Received error packet:
- [Solved] Jedis connect and operate Redis error: Failed to create socket和connect timed out
- Doris Error: there is no scanNode Backend [How to Solve]
- Java Error: No enclosing instance of type Main is accessible. Must qualify the allocation with an encl
- Mybatis sets the primary key Auto-Increment error: No setter found for the keyProperty
- [Solved] No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.errError: Network Error
- How to Solve Error: No suitable driver found for