當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。