将数据从控制器发送到 jsp
Sending Data from Controller to jsp
After putting $ sign getting this error in browser
我试图将数据从我的控制器发送到 jsp 页面,但它只是打印 -->
{login.UserID}
{login.Password}
Logincontroller.java
@Controller
public class LoginController {
public final static String WELCOME = "Welcome";
public final static String LOGIN = "Login";
@RequestMapping(value ="/login" , method = RequestMethod.GET)
public ModelAndView ShowLogin()
{
ModelAndView mav = new ModelAndView(LOGIN);
return mav;
}
@RequestMapping(value = "/loginProcess", method = RequestMethod.POST)
public ModelAndView LoginUser(@ModelAttribute("login") Login login)
{
ModelAndView model = new ModelAndView(WELCOME);
System.out.println(login.getUserID());
System.out.println(login.getPassword());
//model.addObject("login",login);
return model;
}
}
Welcome.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
</head>
<body>
<h1>{login.UserID}</h1>
<h1>{login.Password}</h1>
</body>
</html>
但我不会在 jsp 中输入名称和密码的值,而是得到 -->
{login.UserID}
{login.Password}
看来您可能需要添加一个 $
像
${login.UserID}
After putting $ sign getting this error in browser
我试图将数据从我的控制器发送到 jsp 页面,但它只是打印 -->
{login.UserID}
{login.Password}
Logincontroller.java
@Controller
public class LoginController {
public final static String WELCOME = "Welcome";
public final static String LOGIN = "Login";
@RequestMapping(value ="/login" , method = RequestMethod.GET)
public ModelAndView ShowLogin()
{
ModelAndView mav = new ModelAndView(LOGIN);
return mav;
}
@RequestMapping(value = "/loginProcess", method = RequestMethod.POST)
public ModelAndView LoginUser(@ModelAttribute("login") Login login)
{
ModelAndView model = new ModelAndView(WELCOME);
System.out.println(login.getUserID());
System.out.println(login.getPassword());
//model.addObject("login",login);
return model;
}
}
Welcome.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
</head>
<body>
<h1>{login.UserID}</h1>
<h1>{login.Password}</h1>
</body>
</html>
但我不会在 jsp 中输入名称和密码的值,而是得到 -->
{login.UserID}
{login.Password}
看来您可能需要添加一个 $
像
${login.UserID}