스프링 MVC를 사용하고 있습니다. 내 컨트롤러에서 나는 스프링 MVC 파일을 찾을 수 없습니다. 예외
MyClass{
public static void readFile(){
File file = new FileReader("myPath/myFile.txt");
...
}
public static void main(String[] args) {
readFile();//No problem
}
}
MyClass에
에서 함수를 호출 컨트롤러 :@Controller
public class MyController{
@RequestMapping(value = "/url", method = RequestMethod.GET)
public String readFile(Locale locale, Model model) {
MyClass.readFile();//File not found exception
....
}
}
읽기 내가 MyClass에의) (주에서 테스트 할 때 작동하지만 서버 및 방문 프로젝트를 실행할 때 "/ url", 이걸 가지고 있어요 :
java.io.FileNotFoundException: myPath/myFile.txt (The system cannot find the path specified)
컨트롤러에 경로를 어떻게 지정합니까?
감사합니다.
아마도 이것은 당신에게 유용 할 수 있습니다. https://stackoverflow.com/questions/36371748/spring-boot-access-static-resources-missing-scr-main-resources – lenach87