@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>
我已经将我的 html 文件放在里面src/main/resources/static/NewFile.html
,如果我使用控制器就像(@RequestMapping("/"))
它只是返回字符串而不是视图一样,它就不起作用。除了我要http://localhost:80/NewFile.html
访问它之外,如果我输入动态值并提交,它不会转到特定的控制器。
我是新手Springboot
。谁能告诉我哪里出错了。