我有一个应用程序,它是使用回弹在后端和反应在前面。在应用程序中,一切都是正确的。我只是想知道,当cURL被移过铬和边缘,然后在邮递员中使用时,它就变成了请求。我不明白它为什么会收到请求。(共享图像中的步骤3)
重复这个场景。我总结了我的密码。
后端:
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController
@CrossOrigin
public class TestApi {
@PostMapping("/uploadFile")
public void uploadFile(@RequestPart MultipartFile multipartFile) {
System.out.println(multipartFile.getName());
}
}用于前端:
import FormControl from '@mui/material/FormControl';
import CssBaseline from '@mui/material/CssBaseline';
import Container from '@mui/material/Container';
import Grid from '@mui/material/Grid';
import React, { useState } from 'react';
import axios from 'axios';
function ManagementAuth() {
const [imageFile, setImageFile] = useState([]);
const fileSelectedHandler = (event) => {
setImageFile(event.target.files[0]);
};
const fileUploadHandler = (event) => {
const fd = new FormData();
fd.append('multipartFile', imageFile, imageFile.name);
axios.post('http://localhost:8080/uploadFile', fd)
.then(res => {
console.log(res);
});
};
return (
<React.Fragment>
<CssBaseline />
<Container maxWidth="sm">
<Grid
container
spacing={0}
direction="column"
alignItems="center"
justifyContent="center"
style={{ minHeight: '80vh' }}
>
<FormControl sx={{ m: 1, width: '35ch' }} variant="standard">
<input type="file" onChange={fileSelectedHandler}/>
<button onClick={fileUploadHandler}>Upload</button>
</FormControl>
</Grid>
</Container>
</React.Fragment>
);
}
export default ManagementAuth;在运行了两个应用程序之后,
发布于 2022-10-22 21:38:41
会把这作为一种评论,但我还不能评论。一个快速的搜索打开了这个https://support.postman.com/hc/en-us/articles/211913929-My-request-is-redirected-to-a-GET-request#:~:text=To%20do%20this%2C%20open%20the,Follow%20original%20HTTP%20method%20option。
您正在经历以下问题之一
期待什么
邮递员会自动重定向返回3xx响应的请求。注意:要检查3xx响应,请使用Postman控制台并验证它是否显示了3xx响应。如果是,则表示重定向。如果没有,请提交支持请求(见下文)。
如何解除对自己的束缚
https://stackoverflow.com/questions/74167232
复制相似问题