本文整理匯總了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;
}
示例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/";
}
示例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;
}
示例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";
}
示例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";
}
示例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";
}
示例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);
}
示例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";
}
示例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";
}
示例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";
}
示例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);
}
示例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");
}
示例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, "出錯,參數錯誤");
}
示例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";
}
示例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/";
}