當前位置: 首頁>>代碼示例>>Java>>正文


Java ModelMap類代碼示例

本文整理匯總了Java中org.springframework.ui.ModelMap的典型用法代碼示例。如果您正苦於以下問題:Java ModelMap類的具體用法?Java ModelMap怎麽用?Java ModelMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModelMap類屬於org.springframework.ui包,在下文中一共展示了ModelMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doLogin

import org.springframework.ui.ModelMap; //導入依賴的package包/類
/**
 * do login
 * @param user userInfo
 * @param request requestInfo
 * @param response responseInfo
 * @param map data
 * @return login result
 * @throws IOException
 */
@RequestMapping(value="login",method = RequestMethod.POST)
public String doLogin(User user, HttpServletRequest request, HttpServletResponse response,ModelMap map) throws IOException{
    if(!StringUtils.isEmpty(user.getName())){
        request.getSession().setAttribute(Constant.SESSION_USER_KEY,user);

        //login success, redirect to home controller, change the url also. if return viewName,can't change url.
        response.sendRedirect("/home");
        return null;
    }else{
        map.put("welcomeMsg",this.msg);
        return "login"; //login failure, return login page
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:23,代碼來源:CommonController.java

示例2: updateUser

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@PostMapping(value="/user/update")
public ExecutionStatus updateUser(ModelMap model, @RequestBody User reqUser) {
	User user = new User();
	user.setId(reqUser.getId());
	user.setFirstName(reqUser.getFirstname());
	user.setLastname(reqUser.getLastname());
	user.setContactNumber(reqUser.getContactNumber());
	user.setAlternateContactNumber(reqUser.getAlternateContactNumber());
	user.setCityCode(reqUser.getCityCode());
	user.setStateCode(reqUser.getStateCode());
	user.setCountryCode(reqUser.getCountryCode());
	user.setAge(reqUser.getAge());
	user.setGender(reqUser.getGender());
	userService.update(user);
	return new ExecutionStatus("USER_ACCOUNT_UPDATED", "User account successfully updated");
}
 
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:17,代碼來源:UserAccountController.java

示例3: 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" );
}
 
開發者ID:csap-platform,項目名稱:csap-core,代碼行數:18,代碼來源:HostPortal.java

示例4: signin

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@RequestMapping(value = "/signin", method = {
        RequestMethod.POST})
public String signin(ModelMap map, User user, HttpServletRequest request) {

    String error;
    UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPasswd());
    token.setRememberMe(null != request.getParameter("rememberme") ? true : false);
    try {
        Subject subject = SecurityUtils.getSubject();
        subject.login(token);
        subject.getSession().setAttribute("curUser", userService.findByUsername((String) subject.getPrincipal()));
        return "redirect:/dashboard/console";
    } catch (UnknownAccountException uae) {
        error = "用戶名錯誤!";
    } catch (IncorrectCredentialsException ice) {
        error = "密碼錯誤!";
    } catch (LockedAccountException lae) {
        error = "用戶被鎖定!";
    }
    map.addAttribute("error", error);
    return "signin";
}
 
開發者ID:melonlee,項目名稱:PowerApi,代碼行數:23,代碼來源:AuthController.java

示例5: roleMenu

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@ApiOperation(value = "修改角色菜單")
@PostMapping(value = "/role/update/menu")
@RequiresPermissions("sys.permisson.roleMenu.update")
public Object roleMenu(ModelMap modelMap, @RequestBody List<SysRoleMenu> list) {
	Long roleId = null;
	Long userId = WebUtil.getCurrentUser();
	for (SysRoleMenu sysRoleMenu : list) {
		if (sysRoleMenu.getRoleId() != null) {
			if (roleId != null && roleId != sysRoleMenu.getRoleId()) {
				throw new IllegalParameterException("參數錯誤.");
			}
			roleId = sysRoleMenu.getRoleId();
		}
		sysRoleMenu.setCreateBy(userId);
		sysRoleMenu.setUpdateBy(userId);
	}
	sysAuthorizeService.updateRoleMenu(list);
	return setSuccessModelMap(modelMap);
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:20,代碼來源:SysAuthorizeController.java

示例6: updateAvatar

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@ApiOperation(value = "修改用戶頭像")
@PostMapping(value = "/update/avatar")
public Object updateAvatar(HttpServletRequest request, ModelMap modelMap) {
	List<String> fileNames = UploadUtil.uploadImage(request);
	if (fileNames.size() > 0) {
		SysUser param = new SysUser();
		param.setId(WebUtil.getCurrentUser());
		String filePath = UploadUtil.getUploadDir(request) + fileNames.get(0);
		// String avatar = UploadUtil.remove2DFS("sysUser", "user" +
		// sysUser.getId(), filePath).getRemotePath();
		// String avatar = UploadUtil.remove2Sftp(filePath, "user" +
		// sysUser.getId());
		param.setAvatar(filePath);
		return super.update(modelMap, param);
	} else {
		setModelMap(modelMap, HttpCode.BAD_REQUEST);
		modelMap.put("msg", "請選擇要上傳的文件!");
		return modelMap;
	}
}
 
開發者ID:tb544731152,項目名稱:iBase4J,代碼行數:21,代碼來源:SysUserController.java

示例7: regin

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@ApiOperation(value = "用戶注冊")
@PostMapping("app/regin")
public Object regin(ModelMap modelMap, @RequestBody SysUser sysUser) {
	Assert.notNull(sysUser.getAccount(), "ACCOUNT");
	Assert.notNull(sysUser.getPassword(), "PASSWORD");
	sysUser.setPassword(SecurityUtil.encryptPassword(sysUser.getPassword()));
	provider.execute(new Parameter("sysUserService", "update").setModel(sysUser));
	try {
		String token = SecurityUtil.encryptPassword(sysUser.getAccount() + DateUtil.getDateTime("yyyyMMddHHmmss"));
		TokenUtil.setTokenInfo(token, sysUser.getAccount());
		modelMap.put("token", token);
	} catch (Exception e) {
		logger.error("", e);
	}
	throw new IllegalArgumentException(Resources.getMessage("LOGIN_FAIL"));
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:17,代碼來源:LoginController.java

示例8: uploadFile2Ftp

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@RequestMapping("/file")
@ApiOperation(value = "上傳文件")
public Object uploadFile2Ftp(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
	List<String> fileNames = UploadUtil.uploadFile(request);
	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("file", objectId, filePath).getRemotePath();
			resultList.add(file);
		}
		modelMap.put("fileNames", resultList);
		return setSuccessModelMap(modelMap);
	} else {
		setModelMap(modelMap, HttpCode.BAD_REQUEST);
		modelMap.put("msg", "請選擇要上傳的文件!");
		return modelMap;
	}
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:21,代碼來源:UploadController.java

示例9: uploadImageData2Ftp

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@RequestMapping("/imageData")
@ApiOperation(value = "上傳圖片")
public Object uploadImageData2Ftp(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
	List<String> fileNames = UploadUtil.uploadImageData(request);
	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;
	}
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:21,代碼來源:UploadController.java

示例10: update

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@ApiOperation(value = "修改專題")
@RequiresPermissions("cms:topic:update")
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
public String update(@PathVariable("id") int id, ModelMap modelMap) {
	CmsTopic topic = cmsTopicService.selectByPrimaryKey(id);
	modelMap.put("topic", topic);
	return "/manage/topic/update.jsp";
}
 
開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:9,代碼來源:CmsTopicController.java

示例11: update

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@ApiOperation(value = "修改權限")
@RequiresPermissions("upms:permission:update")
@RequestMapping(value = "/update/{id}", method = RequestMethod.GET)
public String update(@PathVariable("id") int id, ModelMap modelMap) {
    UpmsSystemExample upmsSystemExample = new UpmsSystemExample();
    upmsSystemExample.createCriteria()
            .andStatusEqualTo((byte) 1);
    List<UpmsSystem> upmsSystems = upmsSystemService.selectByExample(upmsSystemExample);
    UpmsPermission permission = upmsPermissionService.selectByPrimaryKey(id);
    modelMap.put("permission", permission);
    modelMap.put("upmsSystems", upmsSystems);
    return "/manage/permission/update.jsp";
}
 
開發者ID:youngMen1,項目名稱:-Spring-SpringMVC-Mybatis-,代碼行數:14,代碼來源:UpmsPermissionController.java

示例12: test

import org.springframework.ui.ModelMap; //導入依賴的package包/類
/**
 * This is the way that ajax calls will need to work.
 * '@ResponseBody' is pretty cool maybe?
 * 
 * @param modelMap
 * @return
 */
@RequestMapping("/test")
@ResponseBody
public String test(ModelMap modelMap, HttpServletRequest request)
   {
	promptPassword(request);
	return "[0, 1, 2, 3]";
   }
 
開發者ID:ForJ-Latech,項目名稱:fwm,代碼行數:15,代碼來源:HelloController.java

示例13: doLogin

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@RequestMapping("/login")
public String doLogin(ModelMap map, HttpSession httpSession, String account, String password) {
	System.out.println("1--login--賬戶是:\t" + account);
	System.out.println("1--login--密碼是:\t" + password);
	httpSession.setAttribute("account", account);
	httpSession.setAttribute("password", password);
	map.addAttribute("account", account);
	return "thymeleaf/index";
}
 
開發者ID:timebusker,項目名稱:spring-boot-redis,代碼行數:10,代碼來源:LoginController.java

示例14: toMenu

import org.springframework.ui.ModelMap; //導入依賴的package包/類
/**
 * 進入角色資源權限頁麵
 * @param id
 * @param map
 * @return
 */
@RequestMapping(value = "menu",method = RequestMethod.GET)
public String toMenu(int id,ModelMap map){
    map.put("menus",new Gson().toJson(roleMenuService.selectByRoleId(id)));
    map.put("roleid",id);
    return "role/menu";
}
 
開發者ID:RayeWang,項目名稱:easyadmin,代碼行數:13,代碼來源:RoleController.java

示例15: close

import org.springframework.ui.ModelMap; //導入依賴的package包/類
@PostMapping("/close")
@ApiOperation(value = "暫停任務")
@RequiresPermissions("sys.task.scheduled.close")
public Object close(@RequestBody TaskScheduled scheduled, ModelMap modelMap) {
	Assert.notNull(scheduled.getTaskGroup(), "TASKGROUP");
	Assert.notNull(scheduled.getTaskName(), "TASKNAME");
	Parameter parameter = new Parameter(getService(), "closeTask").setModel(scheduled);
	provider.execute(parameter);
	return setSuccessModelMap(modelMap);
}
 
開發者ID:youngMen1,項目名稱:JAVA-,代碼行數:11,代碼來源:ScheduledController.java


注:本文中的org.springframework.ui.ModelMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。