请帮忙解释下以下的代码中Terminal terminal=(Terminal)httpRequest.getAttribute("terminal");?Java

问题描述:

请帮忙解释下以下的代码中Terminal terminal=(Terminal)httpRequest.getAttribute("terminal");?Java
@RequestMapping("GetCodeReSend")
@ResponseBody
public Map GetCodeReSend(@RequestParam("mobilePhone")String mobilePhone,
@RequestParam("getCode")String getCode,
HttpServletRequest httpRequest){
HashMap response=new HashMap();
Terminal terminal=(Terminal)httpRequest.getAttribute("terminal");
int checkCode=parcelDao.getGetCodeByPhoneNum(mobilePhone, terminal);
if(checkCode!=-1){
String msg="YouBox:您的取件码是: "+checkCode;
SendSMSHelper.send(msg, mobilePhone);
response.put("responseCode", "0");
}else{
response.put("responseCode", "1");
}
return response;
}
}
请帮忙解释下以下的代码中Terminal terminal=(Terminal)httpRequest.getAttribute("terminal");的作用?

得到,request里 绑定到名叫“terminal”的session 的值,
httpRequest.getAttribute(),就是获取session值,其中挂号里的参数就是session的名字,
这个session,你可以理解像map差不多,一个名字对应一个值