当前位置: 首页>>代码示例>>Java>>正文


Java Model类代码示例

本文整理汇总了Java中org.springframework.ui.Model的典型用法代码示例。如果您正苦于以下问题:Java Model类的具体用法?Java Model怎么用?Java Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Model类属于org.springframework.ui包,在下文中一共展示了Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exception

import org.springframework.ui.Model; //导入依赖的package包/类
@ExceptionHandler(Throwable.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView exception(final Throwable throwable, final Model model) {
    logger.error("Exception during execution of SpringSecurity application", throwable);
    StringBuffer sb = new StringBuffer();
    sb.append("Exception during execution of Spring Security application!   ");

    sb.append((throwable != null && throwable.getMessage() != null ? throwable.getMessage() : "Unknown error"));

    if (throwable != null && throwable.getCause() != null) {
        sb.append(" root cause: ").append(throwable.getCause());
    }
    model.addAttribute("error", sb.toString());

    ModelAndView mav = new ModelAndView();
    mav.addObject("error", sb.toString());
    mav.setViewName("error");

    return mav;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:21,代码来源:ErrorController.java

示例2: hasRole

import org.springframework.ui.Model; //导入依赖的package包/类
@PreAuthorize("hasRole('ROLE_MANAGER') or hasRole('ROLE_LIVREUR')")
@RequestMapping(value="/multiDelivery", method=RequestMethod.POST)
@Transactional
public String multiDelivery(@RequestParam List<Long> listeIds, Model uiModel) {
	
	for(Long id : listeIds){
		try {
			Card card = Card.findCard(id);
			card.setDeliveredDate(new Date());
			card.merge();
		} catch (Exception e) {
			log.info("La carte avec l'id suivant n'a pas été marquée comme livrée : " + id, e);
		}
	}
	uiModel.asMap().clear();
	return "redirect:/manager/";
}
 
开发者ID:EsupPortail,项目名称:esup-sgc,代码行数:18,代码来源:ManagerCardController.java

示例3: remoteImportTemplate

import org.springframework.ui.Model; //导入依赖的package包/类
/**
 * 通过res.weiunity.com的CDN获取制定的模版,远程获取模版文件,将当前网站应用此模版。
 * <br/>模版文件包含模版页面,模版变量、栏目
 */
@RequestMapping("remoteImportTemplate")
@ResponseBody
public BaseVO remoteImportTemplate(HttpServletRequest request, Model model,
		@RequestParam(value = "templateName", required = false , defaultValue="") String templateName){
	if(templateName.length() == 0){
		return error("请选择要远程获取的模版");
	}
	
	HttpUtil http = new HttpUtil(HttpUtil.UTF8);
	HttpResponse hr = http.get(G.RES_CDN_DOMAIN+"template/"+templateName+"/template.wscso");
	if(hr.getCode() - 404 == 0){
		return error("模版不存在");
	}
	
	BaseVO vo = templateService.importTemplate(hr.getContent(), true);
	if(vo.getResult() - BaseVO.SUCCESS == 0){
		//导入完毕后,还要刷新当前的模版页面、模版变量缓存。这里清空缓存,下次使用时从新从数据库加载最新的
		request.getSession().setAttribute("templatePageListVO", null);
		Func.getUserBeanForShiroSession().setTemplateVarCompileDataMap(null);
		Func.getUserBeanForShiroSession().setTemplateVarMapForOriginal(null);
		
		AliyunLog.addActionLog(getSiteId(), "云端导入模版文件成功!");
	}
	return vo;
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:30,代码来源:TemplateController.java

示例4: IrAModificarCat

import org.springframework.ui.Model; //导入依赖的package包/类
@RequestMapping(value = "/modificarCat", method = RequestMethod.POST)
 public String IrAModificarCat(HttpSession session,Model model,@RequestParam("categoria") Long cat) throws BusinessException {
Categoria categor=Services.getSystemServices().findCategoriaById(cat);
model.addAttribute("cat", categor);
String palabras="";
for(String pal:categor.getPalabrasNoPermitidas()){
	palabras+=pal+";";
}
model.addAttribute("palabrasNoPermitidas", palabras);
DateFormat format = new SimpleDateFormat("dd/MM/yyy");
String fin = format.format(categor.getFechaFin());
String inicio = format.format(categor.getFechaInicio());
model.addAttribute("fechaInicio", inicio);
model.addAttribute("fechaFin", fin);

 		return "editarCategoria";
 }
 
开发者ID:Arquisoft,项目名称:participationSystem3b,代码行数:18,代码来源:AdminController.java

示例5: selectArticleList

import org.springframework.ui.Model; //导入依赖的package包/类
/**
 * 加载分页列表数据
 *
 * @param model
 * @return
 */
@RequestMapping("/article/list")
public String selectArticleList(Page pages, Model model) {
    Page<ArticleVo> page;
    page = iArticleService.selectArticleList(new Page(pages.getCurrent(), 5));
    model.addAttribute("page", page);

    return "blog/main";
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:15,代码来源:MenuController.java

示例6: login

import org.springframework.ui.Model; //导入依赖的package包/类
@RequestMapping(value = "/react/login.html", method = RequestMethod.GET)
public String login(@RequestParam(name = "error", required = false) String error, Model model) {
	try {
		if (error.equalsIgnoreCase("true")) {
			String errorMsg = "Login Error";
			model.addAttribute("errorMsg", errorMsg);
		} else {
			model.addAttribute("errorMsg", error);
		}
	} catch (NullPointerException e) {
		logger.info("LoginController#form task started.");
		return "login-form";
	}
	logger.info("LoginController#form task started.");
	return "login-form";
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:17,代码来源:LoginController.java

示例7: testController

import org.springframework.ui.Model; //导入依赖的package包/类
@RequestMapping(value = TokenManagerTest.TEST_MAPPING, method = RequestMethod.GET)
public void testController(HttpSession session, Model model) {

    TokenManager tokenman = new TokenManager("suffix");
    tokenman.addToken(session);
    tokenman.addToken(model);

    assertTrue(tokenman.getTokenFrom(session) != -1);
    assertTrue(tokenman.getTokenFrom(model) != -1);
    assertTrue(tokenman.isTokenValid(session, model));

    tokenman.deleteTokenFrom(session);
    assertFalse(tokenman.isTokenValid(session, model));

    tokenman.addToken(session);
    tokenman.deleteTokenFrom(model);
    assertFalse(tokenman.isTokenValid(session, model));

    tokenman.addToken(model);
}
 
开发者ID:remipassmoilesel,项目名称:simple-hostel-management,代码行数:21,代码来源:TokenManagerTestController.java

示例8: doChangePassword

import org.springframework.ui.Model; //导入依赖的package包/类
@Transactional
@RequestMapping(value = "/changePassword", method = RequestMethod.POST)
public String doChangePassword(@Valid @ModelAttribute UserModel newUserModel, BindingResult bindingResult, Model model) {

	// Get user from DB
	UserModel user = null;
	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
	List<UserModel> userList = userRepository.findByUsername(auth.getName());
	user = userList.get(0);
	
	// Update DB
	UserModel newUser = new UserModel(user.getUsername(), passwordEncoder.encode(newUserModel.getPassword()), user.getEmail_address());
	newUser.setActivated(true);
	userRepository.delete(user);
	userRepository.save(newUser);

	return "index";
}
 
开发者ID:imaTowan,项目名称:Towan,代码行数:19,代码来源:RegisterController.java

示例9: list

import org.springframework.ui.Model; //导入依赖的package包/类
/**
 * 列表.
 */
@RequestMapping("disk-list")
public String list(@RequestParam("u") String u,
        @RequestParam(value = "path", required = false) String path,
        Model model) {
    if (path == null) {
        path = "";
    }

    String userId = u;

    List<DiskShare> diskShares = diskShareManager.findBy("creator", userId);
    model.addAttribute("diskShares", diskShares);
    model.addAttribute("path", path);

    return "disk/disk-list";
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:20,代码来源:DiskController.java

示例10: mediaFilmSubmit

import org.springframework.ui.Model; //导入依赖的package包/类
@PostMapping("/result_film")
public String mediaFilmSubmit(@ModelAttribute Media media, Model model, HttpServletRequest request ) {
    LinkedList<FilmInfo> a = null;
    String maxResult= media.getMaxResult();
    if(media.getTitle().equals("")) return "media_film";
    if (maxResult.equals("")) maxResult="10";
    String languagecode=media.getLanguage();
    if (languagecode.length()!=2) languagecode="";
    try {
        a = APIOperations.filmGetInfo(media.getTitle(), maxResult,languagecode,media.getYear(),media.getOrderBy());
    } catch (UnirestException e) {
        e.printStackTrace();
        return String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    RabbitSend.sendMediaRequest(media.getTitle(),"Film",request);
    if (a.size()==0) return "no_result";
    model.addAttribute("mediaList", a);
    return "result_film";
}
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:20,代码来源:MainController.java

示例11: merge

import org.springframework.ui.Model; //导入依赖的package包/类
@RequestMapping(value = "/{id}.merge.d")
@ResponseBody
public String merge(@PathVariable int id, Model model) {
    JSONObject output = new JSONObject();
    JSONObject server = new JSONObject();
    TopApp topapp = topAppService.get(id);
    try {
        if (topapp != null) {
            model.addAttribute("topapp", topapp);
        }
        server.put("code", SvrResult.OK.getCode());
        server.put("msg", SvrResult.OK.getMsg());
    } catch (Exception e) {
        model.addAttribute("rstCode", 1);
        logger.error("Exception", e);
    }
    output.put("result", server);
    return output.toJSONString(jsonStyle);
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:20,代码来源:TopAppController.java

示例12: index

import org.springframework.ui.Model; //导入依赖的package包/类
@GetMapping("/")
public Mono<String> index(Model model) {
	model.addAttribute("images",
		imageService
			.findAllImages()
			.map(image -> new HashMap<String, Object>() {{
				put("id", image.getId());
				put("name", image.getName());
				put("comments",
					// tag::comments[]
					restTemplate.exchange(
						"http://COMMENTS/comments/{imageId}",
						HttpMethod.GET,
						null,
						new ParameterizedTypeReference<List<Comment>>() {},
						image.getId()).getBody());
				// end::comments[]
			}})
	);
	return Mono.just("index");
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:22,代码来源:HomeController.java

示例13: editPermission

import org.springframework.ui.Model; //导入依赖的package包/类
/**
 * 编辑资源
 * @param id 资源的id,Permission.id 
 */
@RequiresPermissions("adminRolePermission")
@RequestMapping("editPermission")
public String editPermission(@RequestParam(value = "id", required = true) int id,Model model, HttpServletRequest request){
	if(id>0){
		Permission permission = sqlService.findById(Permission.class, id);
		if(permission!=null){
			String parentPermissionDescription="顶级";
			if(permission.getParentId()>0){
				Permission parentPermission = sqlService.findById(Permission.class, permission.getParentId());
				parentPermissionDescription = parentPermission.getName() +","+ parentPermission.getDescription();
			}
			
			ActionLogCache.insert(request, permission.getId(), "进入修改资源Permission页面", "所属上级:"+parentPermissionDescription);
			
			model.addAttribute("permission", permission);
			model.addAttribute("parentPermissionDescription", parentPermissionDescription);
			return "iw/admin/role/permission";
		}
	}
	return error(model, "出错,参数错误");
}
 
开发者ID:xnx3,项目名称:wangmarket,代码行数:26,代码来源:RoleAdminController_.java

示例14: cuenta

import org.springframework.ui.Model; //导入依赖的package包/类
@RequestMapping("/cuenta")
public String cuenta(Model model) {
	Usuario usuario = sessionService.getUsuarioActual();
	if (usuario == null) {
		return "redirect:/";
	}
	
	List<Apuesta> apuestasGanadas= apuestaService.findApuestaUserGanada(usuario);
	List<Apuesta> apuestasPerdidas = apuestaService.findApuestaUserPerdida(usuario);
	List<Apuesta> apuestasNoFinalizadas = apuestaService.findApuestaUserNoFinalizada(usuario);

	model.addAttribute("usuario", usuario);
	model.addAttribute("apuestasGanadas", apuestasGanadas);
	model.addAttribute("apuestasPerdidas", apuestasPerdidas);
	model.addAttribute("apuestasNoFinalizadas", apuestasNoFinalizadas);
	
	return "cuenta";
}
 
开发者ID:arubioVK,项目名称:La-Apostada,代码行数:19,代码来源:UsuarioController.java

示例15: delete

import org.springframework.ui.Model; //导入依赖的package包/类
@RequestMapping("/{creatorName}/{repositoryName}/delete")
public String delete(Model model,
		@PathVariable("creatorName") String creatorName,
		@PathVariable("repositoryName") String repositoryName) {
	Repository repository = repositoryService.get(creatorName+"/"+repositoryName);
	Weaver currentWeaver = weaverService.getCurrentWeaver();
	List<String> tags = new ArrayList<String>();
	tags.add("@"+repository.getName());
	
	if(repositoryService.delete(currentWeaver, repository))
		for(Post post:postService.getPosts(tags, null, null, "", 1, Integer.MAX_VALUE)) // 저장소에 쓴 글 모두 삭제
			postService.delete(post);
		
	else{
		model.addAttribute("say", "삭제하지 못하였습니다!!!");
		model.addAttribute("url", "/repository/"+creatorName+"/"+repositoryName);
		return "/alert";
	}

	return "redirect:/repository/";
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:22,代码来源:RepositoryController.java


注:本文中的org.springframework.ui.Model类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。