0
@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>
我已经把里面src/main/resources/static/NewFile.html
我的HTML文件,如果我用控制器喜欢(@RequestMapping("/"))
这只是返回,而不是观点字符串它不工作除此之外,我正在给http://localhost:80/NewFile.html
进行访问,如果我输入动态值并提交,则不会访问特定的控制器。我的新手Springboot
。任何人都可以告诉我我哪里出错了。试图检索控制用户输入的值,并在SpringBoot应用它添加到MySQL数据库
如果它击中API,然后使用调试器来跟踪流量,并得到问题 – Aman
当我尝试访问该API使用http:// localhost:80/addPerson,它给出这样的错误有一个意外的错误(键入=内部服务器错误,状态= 500)。 此类的ID必须在调用save()之前手动分配:com.gmt.crud.person.Person;嵌套的异常是org.hibernate.id.IdentifierGenerationException:在调用save()之前,必须手动分配此类的ids:com.gmt.crud.person.Person – NaveeN
但是当我尝试通过Html页面时,输入值并点击提交它不会去那个api。它只是卡住了。 – NaveeN