I'm using Spring MVC. In my controller I called a function from MyClass
MyClass{
public static void readFile(){
File file = new FileReader("myPath/myFile.txt");
...
}
public static void main(String[] args) {
readFile();//No problem
}
}
controller:
@Controller
public class MyController{
@RequestMapping(value = "/url", method = RequestMethod.GET)
public String readFile(Locale locale, Model model) {
MyClass.readFile();//File not found exception
....
}
}
The reading works when I test it in the main() of MyClass, but when I run the project on server and visit "/url", I got this:
java.io.FileNotFoundException: myPath/myFile.txt (The system cannot find the path specified)
How do I specify the path in the controller?
Thank you for your time.