Spring boot 尝试使用spring表单标记库在spring boot中从一个JSP文件夹移动到另一个JSP文件夹
我正在开发一个spring启动应用程序,对于UI页面设计,我正在使用spring表单标记库。jsp中有一个链接“所有联系人”。我的要求是,当我单击要移动到“viewContact.jsp”页面的所有联系人链接时。但是我犯了一个错误 请评论并帮助我如何解决此问题 index.jspSpring boot 尝试使用spring表单标记库在spring boot中从一个JSP文件夹移动到另一个JSP文件夹,spring-boot,jsp,spring-form,Spring Boot,Jsp,Spring Form,我正在开发一个spring启动应用程序,对于UI页面设计,我正在使用spring表单标记库。jsp中有一个链接“所有联系人”。我的要求是,当我单击要移动到“viewContact.jsp”页面的所有联系人链接时。但是我犯了一个错误 请评论并帮助我如何解决此问题 index.jsp 联系人姓名 联系电子邮件 联系电话 viewContact.jsp 查看联系人表单 查看联系人表单 联系人姓名 联系电子邮件 联系电话 ${contact.name} ${contact.email} ${con
联系人姓名
联系电子邮件
联系电话
viewContact.jsp
查看联系人表单
查看联系人表单
联系人姓名
联系电子邮件
联系电话
${contact.name}
${contact.email}
${contact.cnum}
contactInfoController.java
@GetMapping(“/viewAll”)
公共字符串handlevelContactDTLSLink(模型){
List allContacts=contactservice.getAllContacts();
model.addAttribute(“联系人”,所有联系人);
返回“查看联系人”;
}
错误页
它给你的
404
错误。确保路径正确。另外,items=“contact”
应该是items=“${contact}”
谢谢你。我已经解决了问题。它给你的404
错误。确保路径正确。另外,items=“contact”
应该是items=“${contact}”
谢谢swati。我已经解决了这些问题。
<form:form method="POST" action="/submit" modelAttribute="contact" >
<table align="center" cellpadding="10" cellspacing="10"
bgcolor="#98AFC7">
<tr>
<td>Contact Name</td>
<td><form:input type="text" path="name"/></td>
</tr>
<tr>
<td>Contact Email</td>
<td><form:input type="text" path="email"/></td>
</tr>
<tr>
<td>Contact Number</td>
<td><form:input type="text" path="num"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Register"></td>
</tr>
<tr>
<td><a href="viewAll">All Contacts</a></td>
</tr>
</table>
</form:form>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>View Contacts Form</title>
</head>
<body bgcolor="#BCC6CC">
<h1 align="center">View Contact Form</h1>
<table>
<tr>
<th>Contact Name</th>
<th>Contact Email</th>
<th>Contact Number</th>
</tr>
<c:forEach items="contact" var="contact">
<tr>
<td>${contact.name}</td>
<td>${contact.email}</td>
<td>${contact.cnum}</td>
</tr>
</c:forEach>
</table>
</body>
</html>
@GetMapping("/viewAll")
public String handleviewallContactDtlsLink(Model model) {
List<Contact> allContacts = contactservice.getAllContacts();
model.addAttribute("contact", allContacts);
return "viewContact";
}