We create action method for Controller by using public static void
1 2 3 4 5 |
public static void list(){ render(); } |
Whether this method is defined in routes file or not, it will be regarded as an action by Play.
And there's another problem: passing parameters by calling action method directly will be impossible
1 2 3 4 5 6 7 8 9 10 11 |
public static void basicUpload(File file){ Files.copy(file, new File("upload.png")); } public static void upload(File file){ basicUpload(file); } |
The above uploading function will not work, Because the file parameter in basicUpload function is always null (But the file parameter in upload function is not null)
To solve this problem, we need to change the access modifier from public to private
1 2 3 4 5 6 7 8 9 10 11 |
private static void basicUpload(File file){ Files.copy(file, new File("upload.png")); } public static void upload(File file){ basicUpload(file); } |
Now the file parameter in basicUpload function will be valid