Java 模型数据未传输到jsp页面
我使用SpringMVC、JPA(Hibernate)和Jsp设计了一个登录页面 请查找login.jsp:-Java 模型数据未传输到jsp页面,java,spring,spring-mvc,Java,Spring,Spring Mvc,我使用SpringMVC、JPA(Hibernate)和Jsp设计了一个登录页面 请查找login.jsp:- <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<h2>Login page</h2>
<form:form method="POST" modelAttribute="loginBean" action="showProfile">
<table>
<tr>
<td>UserName :<form:input path="userName"/></td>
</tr>
<tr>
<td>Organization Id :<form:input path="OrgId" /></td>
</tr>
<tr>
<td>Password : <form:input path="password" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Submit" /></td>
</tr>
</table>
</form:form>
</body>
</html>
在Login.jsp页面中给出有效的详细信息后,它将重定向到profilePage.jsp,但profilePage.jsp中的数据不正确。请帮助我理解我在哪里犯了错误
profilePage.jsp显示在以下位置:-
用户名密码
${staff.userName}${staff.password}
未显示此变量的值。profilePage.jsp:page指令中的Add
isaligned=“false”
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" isELIgnored="false"%>
profilePage.jsp:在页面指令中添加
isaligned=“false”
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" isELIgnored="false"%>
这是行不通的。它只是显示用户名密码。这不起作用。它只是显示用户名和密码
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" isELIgnored="false"%>
@Controller
public class LoginController {
@RequestMapping(value = "/", method = RequestMethod.GET)
public String showLoginPage(Model model) {
model.addAttribute("loginBean", new LoginBean());
return "login";
}
@RequestMapping(value = "/showProfile", method = RequestMethod.POST)
public String redirectToprofile(@ModelAttribute("loginBean") LoginBean loginBean , Model model) {
StaffServiceImpl staffServiceImpl = new StaffServiceImpl();
Staff staff = staffServiceImpl.authenticateStaff(loginBean);
if (null != staff) {
model.addAttribute("staffData",staff);
return "profilePage";
}
return "profileNotFound";
}