Home > Back-end >  The map in the JSP access ModelAndView
The map in the JSP access ModelAndView

Time:09-17

A typical SSM framework project,

The back-end code is as follows:
 
Public ModelAndView toContinueEdit (it request,
@ RequestParam (" mailId ") Integer mailId
) {
ModelAndView mv=new ModelAndView ("... ");
Map Param=new HashMap (a);
Param. Put (" mail_id, "mailId);
Param. Put (" the type_name ", "continueEdit");
Mv. AddObject (" param ", param);
Return the mv;
}

The front-end code is as follows:

 
<% @ page language="Java" contentType="text/HTML. Charset=utf-8 "
PageEncoding="utf-8" isELIgnored="false" % & gt;
<% @ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" % & gt;
Var gnMailId='${param. Mail_id}';
Var gsType='${param. The type_name}';
</script>

-
The web.xml configuration is as follows:
 
XMLNS: xsi="http://www.w3.org/2001/XMLSchema-instance"
XMLNS="http://java.sun.com/xml/ns/javaee"
XMLNS: JSP="http://java.sun.com/xml/ns/javaee/jsp"
Xsi: schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
Id="WebApp_ID
"Version="3.0" & gt;


Problem: gnMailId, gsType obtained is "".

CodePudding user response:

Var gnMailId='${param. Mail_id}';
Var gsType='${param. The type_name}';
Your quote, he certainly will give you turn this into a string,

CodePudding user response:

Param is the key word, you'd better not use param parameter name
If use ${param. XXX} this stitching parameters is to obtain the browser address
Moderandview should be also belongs to the forward, is equal to obtain your access controller stitching parameters in the url

Such as the controller is http://127.0.0.1:8080/test.do? TestParam=1

Return the view in the JSP after ${param. TestParam} can get

CodePudding user response:

Your entity class didn't write a whole?

CodePudding user response:

Back to the Map by modelAndView, have nothing to do with entity class,

Now is not clear because of the web. XML is not configured properly, or not written to the JSP, or that there was something wrong with the grammar of the reference,

CodePudding user response:

refer to the second floor dkwuxiang response:
param is the key word, you'd better not use param parameter name
If use ${param. XXX} this stitching parameters is to obtain the browser address
Moderandview should be also belongs to the forward, is equal to obtain your access controller stitching parameters in the url

Such as the controller is http://127.0.0.1:8080/test.do? TestParam=1

Return the view in the JSP after ${param. TestParam} can get


This didn't pay attention, take time to verify,

CodePudding user response:

. ${param name} is equivalent to the request. The getParameter (" name "), {param [name]} is the same

Look at the changing param name again
  • Related