前端ajax的url写的dis,后端controller类@RequestMapping的value上没有写,但是在方法上写了@RequestMapping("/dis"),一直报错,无意间将类上面写成@RequestMapping("/dis"),搜索栏出现ajax发送的数据。
最后将前端的url改成cam/dis
后端改为
@RequestMapping("/cam")
@Controller
@ResponseBody
public class DisplayController {
/*
访问地址localhost:8080/Dis
params为文件夹路径
cut为图片所在文件夹
* */
@RequestMapping("/dis")
public ArrayList<String> SendPicturePath(Path path) {
ArrayList<String> fileList = new ArrayList<String>();
//将图片所在文件夹信息送过去,切割成相对路径
GetPicturePath getPicture =new GetPicturePath(path.getCut());
//创建文件夹的位置 path.getParams().split(path.getCut())[0]
fileList = getPicture.getFiles(path.getParams());
return fileList;
}
}
就达到前后端互通数据了