本文整理汇总了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/";
}