Hibernate 如何通过单击超链接生成动态url
我很难通过点击hyperkink生成动态url 这是我的表单employeeForm.jsp的视图:Hibernate 如何通过单击超链接生成动态url,hibernate,jsp,spring-mvc,jstl,Hibernate,Jsp,Spring Mvc,Jstl,我很难通过点击hyperkink生成动态url 这是我的表单employeeForm.jsp的视图: <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> <html> <head> <title>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>
<title>Employee Form</title>
</head>
<body>
<h2>Employee Information</h2>
<form:form method="POST" action="/result">
Employee ID: <input type="text" name="employeeID">
<br />
Profile Picture: <input type="text" name="profilePicture">
<br />
Name: <input type="text" name="name">
<br />
Date of Birth: <input type="text" name="birthDate">
<br />
Gender: <input type="text" name="gender">
<br />
Address: <input type="text" name="address">
<br />
Phone: <input type="text" name="phone">
<br />
E-mail: <input type="text" name="email">
<br />
Designation: <input type="text" name="designation">
<br />
Job Description: <input type="text" name="jobDescription">
<br />
<input type="submit" value="Submit" />
</form:form>
</body>
</html>
这是生成的输出url:
http://localhost:8080/employeeProfile.jsp?employeeID=10
取决于我在表单中设置的id。但是我得到一个错误404,说“请求的资源不可用。”
我知道我显然做错了什么(或更多),我只是不知道是什么。我注意到生成的URL没有通常是项目名称的上下文路径
检查生成的url/
我通过进行以下更改解决了问题:
result.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<c:url value="employeeProfile.jsp" var="displayURL">
<c:forEach var="list" items="${list}">
<c:param name="employeeID" value="${list.employeeID}"/>
</c:forEach>
</c:url>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Result Form</title>
</head>
<body>
<%--<p>Generated URL is <c:out value="${displayURL}" /> </p>--%>
<a href='<c:out value="${displayURL}" />'> This </a>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Result Form</title>
</head>
<body>
<table>
<TH>Id:</th>
<TH>Name:</th>
<c:forEach var="list" items="${list}" >
<tr>
**<td><a href="<c:url value="/employeeProfile?employeeID=${list.employeeID}"/>"/>${list.name}</td>**
</tr>
</c:forEach>
</table>
<%--<p>Generated URL is <c:out value="${displayURL}" /> </p>--%>
<a href='<c:out value="${displayURL}" />'> This </a>
</body>
</html>
成绩表
身份证件:
姓名:
**
就这样。谢谢你的帮助 您标记生成了什么值。我已将该值编辑到我的问题中。这是因为上下文根不可用。您生成的url没有contextroot。应该是我在你的代码中没有发现任何错误。我已经复制了你的代码并运行了。它运行没有任何问题。试着把这条线换成
http://localhost:8080/employeeProfile.jsp?employeeID=10
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Result Form</title>
</head>
<body>
<table>
<TH>Id:</th>
<TH>Name:</th>
<c:forEach var="list" items="${list}" >
<tr>
**<td><a href="<c:url value="/employeeProfile?employeeID=${list.employeeID}"/>"/>${list.name}</td>**
</tr>
</c:forEach>
</table>
<%--<p>Generated URL is <c:out value="${displayURL}" /> </p>--%>
<a href='<c:out value="${displayURL}" />'> This </a>
</body>
</html>