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


Java ModelMap.addAttribute方法代码示例

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


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

示例1: search

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/**
 * @param type Type of data sought
 * @param q Search for a phrase
 * @param page Page number
 * @param pageSize Number of items per page
 * @param modelMap {@link ModelMap}
 * @return The ModelAndView for a list of users (or a list of movies( in the future ))
 */
@GetMapping(value = "/search")
public ModelAndView search(
        @RequestParam final String type,
        @RequestParam final String q,
        @RequestParam(defaultValue = "1") final int page,
        @RequestParam(defaultValue = "1") final int pageSize,
        final ModelMap modelMap
) {
    modelMap.addAttribute("type", type);
    modelMap.addAttribute("q", q);
    modelMap.addAttribute("page", page);
    modelMap.addAttribute("pageSize", pageSize);

    return new ModelAndView("users", modelMap);
}
 
开发者ID:JonkiPro,项目名称:REST-Web-Services,代码行数:24,代码来源:SearchController.java

示例2: handleAdmin

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value="/admin", method = RequestMethod.GET)
public String handleAdmin(ModelMap model, Principal principal ) {
	
	System.out.println("***********LoginController handleAdmin Called***********");

	String name = principal.getName();
	model.addAttribute("username", name);
	model.addAttribute("message", "This is admin area");
	return "admin";
}
 
开发者ID:Illusionist80,项目名称:SpringTutorial,代码行数:11,代码来源:LoginController.java

示例3: all

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequiresPermissions("video:view")
@RequestMapping(value = "/all", method = RequestMethod.GET)
public String all(ModelMap map) {

    List<Video> videos = videoService.findAll();
    map.addAttribute("videos", videos);
    return "/video/index.ftl";
}
 
开发者ID:melonlee,项目名称:LazyAdmin,代码行数:9,代码来源:VideoController.java

示例4: processSignup

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@PostMapping("/sign-up")
public String processSignup(ModelMap model, @Valid SignupForm form, BindingResult result){
    if(result.hasErrors()){
        model.addAttribute(form);
        log.warn("Form contains error {} ", form );
    }else{
        User user = form.toUser();
        signupHelper.signupAndSignInUser(user);
        verifyAction.with(user, "/?welcome=1");
        return "redirect:/verify";
    }
    return "sign-up";
}
 
开发者ID:peterjurkovic,项目名称:travel-agency,代码行数:14,代码来源:SignupController.java

示例5: index

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping("/hello")
public String index(ModelMap map) {
    // 加入一个属性,用来在模板中读取
    map.addAttribute("host", "http://blog.didispace.com");
    // return模板文件的名称,对应src/main/resources/templates/index.html
    return "index";
}
 
开发者ID:xubinux,项目名称:xbin-store,代码行数:8,代码来源:HelloController.java

示例6: validUser

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String validUser(String loginName, String password, HttpServletRequest request, HttpServletResponse response, ModelMap model) {
	logger.debug("login {loginName:" + loginName + ",password:" + password + "}");
	User user = userService.getUserByLoginName(loginName);
	if (user != null && user.getPassword().equals(password)) {
		model.put("message", "登录成功");
	} else {
		model.put("message", "用户验证失败");
	}
	model.addAttribute("loginName", loginName);
	return "test";
}
 
开发者ID:wz12406,项目名称:accumulate,代码行数:13,代码来源:TestController.java

示例7: listUsers

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/**
 * This method will list all existing users.
 */
@RequestMapping(value = {"/adm/list"}, method = RequestMethod.GET)
public String listUsers(ModelMap model) {

    List<AdmUser> users = userService.findAllUsers();
    model.addAttribute("users", users);
    model.addAttribute("loggedinuser", getPrincipal());
    return "userslist";
}
 
开发者ID:mustafamym,项目名称:FeedbackCollectionAndMgmtSystem,代码行数:12,代码来源:SurveyController.java

示例8: index

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@GetMapping("/")
public String index(ModelMap modelMap, Principal principal) {
    long articlesCount = articleService.getArticlesCount(principal.getName());

    List<Article> articles = articleService.getArticlesOfOnePage(principal.getName(), 1);

    modelMap.addAttribute("articles", articles);
    modelMap.addAttribute("articlesCount", articlesCount);
    modelMap.addAttribute("isIndex", true);

    return "article/index";
}
 
开发者ID:ziwenxie,项目名称:leafer,代码行数:13,代码来源:ArticleController.java

示例9: afficher

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value="/afficherSuppressionToDoList", method = RequestMethod.GET)
public String afficher(final ModelMap pModel) {
	//Création d'un objet ToDoList puis Lecture de la table
	final List<ToDoList> lToDoLists = service.RechercherToDoList();
       pModel.addAttribute("todolist", lToDoLists);
       
       return "suppression";
   }
 
开发者ID:Julien35,项目名称:dev-courses,代码行数:9,代码来源:SupprimerToDoListController.java

示例10: propertyEncoder

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping ( "propertyEncoder" )
public String propertyEncoder (	ModelMap modelMap,
								@RequestParam ( value = "path" , required = false , defaultValue = "none" ) String path,
								HttpServletRequest request, HttpSession session )
		throws IOException {

	setCommonAttributes( modelMap, session, "Property Encoder" );
	modelMap.addAttribute( "name", Application.getHOST_NAME() );
	return "misc/property-encoder";
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:11,代码来源:FileRequests.java

示例11: preview

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/**
 * 预览项目文档
 *
 * @param model
 * @param id
 * @return
 */
@RequestMapping(value = "/preview", method = RequestMethod.GET)
public String preview(ModelMap model, @RequestParam(value = "id", required = true) Long id) {
    List<Module> modules = moduleService.selectByProjectId(id);
    model.addAttribute("modules", modules);
    model.addAttribute("project", getProject(id));
    return "project/preview";
}
 
开发者ID:melonlee,项目名称:PowerApi,代码行数:15,代码来源:ProjectController.java

示例12: saveStudentUser

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
/**
  * This method will be called on form submission, handling POST request for
  * saving user in database. It also validates the user input
  */
 @RequestMapping(value = {"/studentregistration"}, method = RequestMethod.POST)
 public String saveStudentUser(@Valid StudentUser user, BindingResult result,
         ModelMap model) {

     if (result.hasErrors()) {
         return "studentregistration";
     }

     /*
* Preferred way to achieve uniqueness of field [sso] should be implementing custom @Unique annotation 
* and applying it on field [sso] of Model class [User].
* 
* Below mentioned peace of code [if block] is to demonstrate that you can fill custom errors outside the validation
* framework as well while still using internationalized messages.
* 
      */
     if (!userService.isStudentUnique(user.getStudentUserId(), user.getEmail())) {
         FieldError ssoError = new FieldError("studentuser", "email", messageSource.getMessage("non.unique.ssoId",
                 new String[]{user.getEmail()}, Locale.getDefault()));
         result.addError(ssoError);
         model.addAttribute("loggedinuser", getPrincipal());
         return "studentregistration";
     }

     userService.saveUser(user);

     model.addAttribute("success", "User " + user.getFirstName() + " " + user.getLastName() + " registered successfully");
     model.addAttribute("loggedinuser", getPrincipal());
     //return "success";
     return "registrationsuccess";
 }
 
开发者ID:mustafamym,项目名称:FeedbackCollectionAndMgmtSystem,代码行数:36,代码来源:AppController.java

示例13: all

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequiresRoles("admin")
@RequiresPermissions("admin:view")
@RequestMapping(value = "/all", method = RequestMethod.GET)
public String all(ModelMap map) {

    List<Admin> admins = adminService.findAll();
    map.addAttribute("admins", admins);
    return "/account/index.ftl";
}
 
开发者ID:melonlee,项目名称:LazyAdmin,代码行数:10,代码来源:AdminController.java

示例14: updateTodo

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@RequestMapping(value = "/update-todo", method = RequestMethod.GET)
public String updateTodo(ModelMap model, @RequestParam int id) {
	Todo todo = service.retrieveTodo(id);
	model.addAttribute("todo", todo);
	return "todo";
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Spring-5.0,代码行数:7,代码来源:TodoController.java

示例15: showSignupForm

import org.springframework.ui.ModelMap; //导入方法依赖的package包/类
@GetMapping("/sign-up")
public String showSignupForm(ModelMap model){
    model.addAttribute(new SignupForm());
    return "sign-up";
}
 
开发者ID:peterjurkovic,项目名称:travel-agency,代码行数:6,代码来源:SignupController.java


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