I am creating a log in page, which will allow the user to sign in. However, when I try to visit http://localhost:8080/index via Google Chrome, I am just seeing "index," nothing else. But it is supposed to display the log in page that I created using HTML and Bootstrap.
Here are the codes of HomeController.java
package com.userFront.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HomeController {
@RequestMapping("/")
public String home() {
return "redirect:/index";
}
@RequestMapping("/index")
public @ResponseBody String index() {
return "index";
}
}
You can find all the project files here: https://drive.google.com/open?id=1fxTWDo_3_iaS4zaav60KaT9OvB-kSjv6
Update:1 I have been advised to remove @ResponseBody from the method index(). But when I do that, the following problem occurs:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Dec 11 17:52:53
There was an unexpected error (type=Internal Server Error, status=500).
Circular view path [index]: would dispatch back to the current handler URL [/index] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
Update 2: Here is the latest version of HomeController class, which I modify based on the advise I receive from @vtx:
package com.userFront.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/")
public String home() {
return "redirect:/index";
}
@RequestMapping("/welcome")
public String index() {
return "index";
}
}
But now, a new error occurs, which says:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Dec 11 18:52:41
There was an unexpected error (type=Not Found, status=404).
No message available
Update 3: As advised by @vtx, I have tried to clean install Maven. However, the following error occurs:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building UserFront 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ userFront ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 30 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ userFront ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to C:\Users\Kanon\eclipse-workspace\UserFront\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.606 s
[INFO] Finished at: 2017-12-11T23:31:14+06:00
[INFO] Final Memory: 18M/227M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project userFront: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Update 4: As suggested by @vtx, I have performed clean installation of Maven.
I have followed stackoverflow.com/questions/19655184/… and stackoverflow.com/questions/19655184/…. Maven is installed cleanly without any error. But now, I am getting "Circular view path" error.
Update 5: @vtx suggested me to use the following code again:
package com.userFront.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/")
public String home() {
return "redirect:/index";
}
@RequestMapping("/welcome")
public String index() {
return "index";
}
}
But once again, I am getting the following error:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Dec 12 00:27:42
There was an unexpected error (type=Not Found, status=404).
No message available
It's getting incredibly frustrating. But I will not give up!