@RestController
@RequestMapping(value="addPerson", method=RequestMethod.GET)
public String addPerson(@RequestParam(value="name", required=false) String Fname, @RequestParam(value="pwd", required=false) String Lname){
Person person= new Person(Fname,Lname);
crudService.addPerson(person);
return "Successfully added " + Fname;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="yellow">
<form action="addPerson" method="get"></form>
<table>
<tr>
<td>Enter Your Name</td>
<td>
<input type="text" name="name">
</td>
</tr>
<tr>
<td>Enter Password</td>
<td>
<input type="password" name="pwd">
</td>
</tr>
<tr>
<td>
<input type="submit" value="SUBMIT">
</td>
</tr>
</table>
</body>
</html>
I have placed my html file inside src/main/resources/static/NewFile.html
and it's not working if I use controller like (@RequestMapping("/"))
it was just returning string instead of the view.Besides that I'm giving http://localhost:80/NewFile.html
to access it and in that if I enter dynamic values and submit, it doesn't go to the specific controller.
I am new to this Springboot
. Can anyone please tell me where I am going wrong.