本文整理匯總了Java中org.springframework.ui.ModelMap.put方法的典型用法代碼示例。如果您正苦於以下問題:Java ModelMap.put方法的具體用法?Java ModelMap.put怎麽用?Java ModelMap.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.ui.ModelMap
的用法示例。
在下文中一共展示了ModelMap.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: viewInput
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping("/view.html")
public String viewInput(String transOrderId, ModelMap model) {
TransOrder item = null;
if(StringUtils.isNotBlank(transOrderId)) {
item = transOrderService.selectTransOrder(transOrderId);
}
if(item == null) {
item = new TransOrder();
model.put("item", item);
return "trans_order/view";
}
JSONObject object = (JSONObject) JSON.toJSON(item);
if(item.getTransSuccTime() != null) object.put("transSuccTime", DateUtil.date2Str(item.getTransSuccTime()));
if(item.getExpireTime() != null) object.put("expireTime", DateUtil.date2Str(item.getExpireTime()));
if(item.getAmount() != null) object.put("amount", AmountUtil.convertCent2Dollar(item.getAmount()+""));
model.put("item", object);
return "trans_order/view";
}
示例2: setModelMap
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
/** 設置響應代碼 */
protected ResponseEntity<ModelMap> setModelMap(ModelMap modelMap, HttpCode code, Object data) {
Map<String, Object> map = InstanceUtil.newLinkedHashMap();
map.putAll(modelMap);
modelMap.clear();
for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
String key = iterator.next();
if (!key.startsWith("org.springframework.validation.BindingResult") && !key.equals("void")) {
modelMap.put(key, map.get(key));
}
}
if (data != null) {
if (data instanceof Page) {
Page<?> page = (Page<?>) data;
modelMap.put("data", page.getRecords());
modelMap.put("current", page.getCurrent());
modelMap.put("size", page.getSize());
modelMap.put("pages", page.getPages());
modelMap.put("total", page.getTotal());
modelMap.put("iTotalRecords", page.getTotal());
modelMap.put("iTotalDisplayRecords", page.getTotal());
} else if (data instanceof List<?>) {
modelMap.put("data", data);
modelMap.put("iTotalRecords", ((List<?>) data).size());
modelMap.put("iTotalDisplayRecords", ((List<?>) data).size());
} else {
modelMap.put("data", data);
}
}
modelMap.put("httpCode", code.value());
modelMap.put("msg", code.msg());
modelMap.put("timestamp", System.currentTimeMillis());
return ResponseEntity.ok(modelMap);
}
示例3: Home
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping(value = "/home", method = RequestMethod.GET)
public String Home(ModelMap map, @RequestParam(name = "species",
required = false, defaultValue = "All") String species)
throws InterruptedException {
Zoo z = Zoo.getInstance();
map.put("z", z);
map.put("z", z.getAllAnimals());
map.put("species", species);
map.put("table", z.getAllAnimalsBySpecies(species));
if (species.equals("All")) {
z.getAllAnimals();
map.put("table", z.getAllAnimals());
} else {
z.getAllAnimalsBySpecies(species);
map.put("table", z.getAllAnimalsBySpecies(species));
}
map.put("getName", z.getName());
return "index";
}
示例4: performancePortal
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping("performance")
public ModelAndView performancePortal(ModelMap modelMap, HttpSession session,
@RequestParam(value = "serviceName", required = false) String serviceNamePort,
@RequestParam(value = "project", required = false) String project,
@RequestParam(value = "life", required = false) String life,
@RequestParam(value = CSAP.HOST_PARAM, required = false) String hostName)
throws IOException {
setCommonAttributes( modelMap, session, "Analytics Portal" );
modelMap.put( "project", project );
modelMap.put( "life", life );
modelMap.addAttribute( "metricLabels", buildMetricLabels() );
return new ModelAndView( "performance/perf-main" );
}
示例5: uploadImage2Ftp
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping("/image")
@ApiOperation(value = "上傳圖片")
public Object uploadImage2Ftp(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
List<String> fileNames = UploadUtil.uploadImage(request, false);
if (fileNames.size() > 0) {
List<String> resultList = InstanceUtil.newArrayList();
for (int i = 0; i < fileNames.size(); i++) {
String filePath = UploadUtil.getUploadDir(request) + fileNames.get(i);
String objectId = UUID.randomUUID().toString().replaceAll("-", "");
String file = UploadUtil.remove2DFS("image", objectId, filePath).getRemotePath();
resultList.add(file);
}
modelMap.put("fileNames", resultList);
return setSuccessModelMap(modelMap);
} else {
setModelMap(modelMap, HttpCode.BAD_REQUEST);
modelMap.put("msg", "請選擇要上傳的文件!");
return modelMap;
}
}
示例6: list
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@GetMapping
public String list(ModelMap model){
List<Person> persons = personMapper.getPersons();
model.put("persons", persons);
return "list";
}
示例7: sinaCallback
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping("callback/sina")
@ApiOperation(value = "微博登錄回調", httpMethod = "GET")
public String sinaCallback(HttpServletRequest request, ModelMap modelMap) {
String host = request.getHeader("host");
try {
String code = request.getParameter("code");
if (StringUtils.isNotBlank(code)) {// 如果不為空
// 獲取token和uid
JSONObject json = ThirdPartyLoginHelper.getSinaTokenAndUid(code, host);
String uid = json.getString("uid");
if (StringUtils.isNotBlank(uid)) {// 如果uid存在
// 獲取第三方用戶信息存放到session中
ThirdPartyUser thirdUser = ThirdPartyLoginHelper.getSinaUserinfo(json.getString("access_token"),
uid);
thirdUser.setProvider("SINA");
thirdPartyLogin(request, thirdUser);
// 跳轉到登錄成功界麵
modelMap.put("retUrl", Resources.THIRDPARTY.getString("third_login_success"));
} else {// 如果未獲取到OpenID
// 跳轉到登錄成功界麵
modelMap.put("retUrl", "-1");
}
} else {// 如果沒有返回令牌,則直接返回到登錄頁麵
// 跳轉到登錄成功界麵
modelMap.put("retUrl", "-1");
}
} catch (Exception e) {
// 跳轉到登錄失敗界麵
modelMap.put("retUrl", "-1");
e.printStackTrace();
}
return "/sns/redirect";
}
示例8: homeHandler
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping("/home.do")
public String homeHandler(HttpServletRequest request, HttpServletResponse response, ModelMap model) throws ServletException {
SessionUser sessionUser = (SessionUser) this.getSessionObject(request, SysConstants.SESSION_USER_KEY);
model.put("sessionUser", sessionUser);
Map<String, Object> param = new HashMap<String, Object>();
List<SeRole> seRoleList = sessionUser.getSeRoleList();
if (seRoleList != null && seRoleList.size() > 0) {
param.put("seRoleList", seRoleList);
List<SeMenu> listUserMenu = seRolemenuService.listSeMenuByUsercode(param);
if (listUserMenu != null && listUserMenu.size() > 0) {
// 拚接菜單
SeMenu rootSeMenu = listUserMenu.remove(0);
MenuTree tree = new MenuTree(rootSeMenu,listUserMenu);
model.put("listUserMenu", tree.buildTree());
}
for(SeMenu seMenu : listUserMenu){
if(!Utils.strIsNull(seMenu.getSourceurl())){
model.put("firstMenu", seMenu);
break;
}
}
}
return "page/home";
}
示例9: permission
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@ApiOperation(value = "用戶權限")
@RequiresPermissions("upms:user:permission")
@RequestMapping(value = "/permission/{id}", method = RequestMethod.GET)
public String permission(@PathVariable("id") int id, ModelMap modelMap) {
UpmsUser user = upmsUserService.selectByPrimaryKey(id);
modelMap.put("user", user);
return "/manage/user/permission.jsp";
}
示例10: setModelMap
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
/** 設置響應代碼 */
protected ResponseEntity<ModelMap> setModelMap(ModelMap modelMap, HttpCode code, Object data) {
Map<String, Object> map = InstanceUtil.newLinkedHashMap();
map.putAll(modelMap);
modelMap.clear();
for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext();) {
String key = iterator.next();
if (!key.startsWith("org.springframework.validation.BindingResult") && !key.equals("void")) {
modelMap.put(key, map.get(key));
}
}
if (data != null) {
if (data instanceof Page) {
Page<?> page = (Page<?>) data;
modelMap.put("data", page.getRecords());
modelMap.put("current", page.getCurrent());
modelMap.put("size", page.getSize());
modelMap.put("pages", page.getPages());
modelMap.put("iTotalRecords", page.getTotal());
modelMap.put("iTotalDisplayRecords", page.getTotal());
} else if (data instanceof List<?>) {
modelMap.put("data", data);
modelMap.put("iTotalRecords", ((List<?>) data).size());
modelMap.put("iTotalDisplayRecords", ((List<?>) data).size());
} else {
modelMap.put("data", data);
}
}
modelMap.put("httpCode", code.value());
modelMap.put("msg", code.msg());
modelMap.put("timestamp", System.currentTimeMillis());
return ResponseEntity.ok(modelMap);
}
示例11: validUser
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String validUser(String loginName, String password, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
logger.debug("login {loginName:" + loginName + ",password:" + password + "}");
User user = userService.getUserByLoginName(loginName);
if (user != null && user.getPassword().equals(password)) {
model.put("message", "登錄成功");
} else {
model.put("message", "用戶驗證失敗");
}
model.addAttribute("loginName", loginName);
return "test";
}
示例12: qqCallback
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@RequestMapping("/callback/qq")
public String qqCallback(HttpServletRequest request, ModelMap modelMap) {
String host = request.getHeader("host");
try {
String code = request.getParameter("code");
if (StringUtils.isNotBlank(code)) {// 如果不為空
// 獲取token和openid
Map<String, String> map = ThirdPartyLoginHelper.getQQTokenAndOpenid(code, host);
String openId = map.get("openId");
if (StringUtils.isNotBlank(openId)) {// 如果openID存在
// 獲取第三方用戶信息存放到session中
ThirdPartyUser thirdUser = ThirdPartyLoginHelper.getQQUserinfo(map.get("access_token"), openId);
thirdUser.setProvider("QQ");
thirdPartyLogin(request, thirdUser);
// 跳轉到登錄成功界麵
modelMap.put("retUrl", Resources.THIRDPARTY.getString("third_login_success"));
} else {// 如果未獲取到OpenID
modelMap.put("retUrl", "-1");
}
} else {// 如果沒有返回令牌,則直接返回到登錄頁麵
modelMap.put("retUrl", "-1");
}
} catch (Exception e) {
modelMap.put("retUrl", "-1");
e.printStackTrace();
}
return "/sns/redirect";
}
示例13: update
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@ApiOperation(value = "修改標簽")
@RequiresPermissions("cms:tag:update")
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
public String update(@PathVariable("id") int id, ModelMap modelMap) {
CmsTag tag = cmsTagService.selectByPrimaryKey(id);
modelMap.put("tag", tag);
return "/manage/tag/update.jsp";
}
示例14: role
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@ApiOperation(value = "用戶角色")
@RequiresPermissions("upms:user:role")
@RequestMapping(value = "/role/{id}", method = RequestMethod.GET)
public String role(@PathVariable("id") int id, ModelMap modelMap) {
// 所有角色
List<UpmsRole> upmsRoles = upmsRoleService.selectByExample(new UpmsRoleExample());
// 用戶擁有角色
UpmsUserRoleExample upmsUserRoleExample = new UpmsUserRoleExample();
upmsUserRoleExample.createCriteria()
.andUserIdEqualTo(id);
List<UpmsUserRole> upmsUserRoles = upmsUserRoleService.selectByExample(upmsUserRoleExample);
modelMap.put("upmsRoles", upmsRoles);
modelMap.put("upmsUserRoles", upmsUserRoles);
return "/manage/user/role.jsp";
}
示例15: permission
import org.springframework.ui.ModelMap; //導入方法依賴的package包/類
@ApiOperation(value = "角色權限")
@RequiresPermissions("upms:role:permission")
@RequestMapping(value = "/permission/{id}", method = RequestMethod.GET)
public String permission(@PathVariable("id") int id, ModelMap modelMap) {
UpmsRole role = upmsRoleService.selectByPrimaryKey(id);
modelMap.put("role", role);
return "/manage/role/permission.jsp";
}