当前位置: 首页>>代码示例>>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;未经允许,请勿转载。