SPRINGMVC with data to JSP page
The first way: through the request domain
Java: Sending values with HttpServletRequest request
Request.setattribute ("User", username); Request.setattribute ("Password", password); stored value
@RequestMapping (value= "Test1") Publicstring Test1 (string username,string password,httpservletrequest request) {Request.setattribute ("User", username); Request.setattribute ("Password", password); if("admin". Equals (username) && "123". Equals (password)) {//Login Successful return"Success"; } Else{//Logon FailureSystem.out.println (username); return"Fail"; } }
Value: In the jump to the success.jsp page write: ${requestscope.user}
<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"iselignored="false"%><% StringBasePath=Request.getscheme ()+"://"+Request.getservername ()+":"+Request.getserverport ()+Request.getcontextpath ()+"/";%><!DOCTYPE HTML><HTML><Head> <Basehref= "<%=basepath%>"> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"> <title>New JSP</title></Head><Body> <H1>Login successful</H1> <!--saving data through the request domain -${requestscope.user}</Body></HTML>
The second way: with data through the model
SPRINGMVC_ with data and unified exception handling problem