Here are the examples of the java api org.springframework.ui.ModelMap.addAttribute() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
697 Examples
19
View Source File : UserResource.java
License : Apache License 2.0
Project Creator : yifanzheng
License : Apache License 2.0
Project Creator : yifanzheng
@GetMapping("/index")
public String index(ModelMap map) {
map.addAttribute("name", "thymeleaf-imooc");
map.addAttribute("content", "<font color='green'>kevin</font>");
return "index";
}
19
View Source File : HelloController.java
License : GNU General Public License v3.0
Project Creator : xubinux
License : GNU General Public License v3.0
Project Creator : xubinux
@RequestMapping("/hello")
public String index(ModelMap map) {
// 加入一个属性,用来在模板中读取
map.addAttribute("host", "http://blog.didispace.com");
// return模板文件的名称,对应src/main/resources/templates/index.html
return "index";
}
19
View Source File : UserService.java
License : GNU General Public License v3.0
Project Creator : wlhbdp
License : GNU General Public License v3.0
Project Creator : wlhbdp
public ModelMap login(User user) {
ModelMap modelMap = new ModelMap();
User user2 = userRepository.getUserByName(user.getName());
if (user2 == null) {
modelMap.addAttribute("result", false);
modelMap.addAttribute("msg", "用户不存在");
return modelMap;
}
if (!bCryptPreplacedwordEncoder.matches(user.getPreplacedword(), user2.getPreplacedword())) {
modelMap.addAttribute("result", false);
modelMap.addAttribute("msg", "密码错误");
return modelMap;
}
modelMap.addAttribute("result", true);
modelMap.addAttribute("user", user2);
return modelMap;
}
19
View Source File : UserController.java
License : GNU General Public License v3.0
Project Creator : wlhbdp
License : GNU General Public License v3.0
Project Creator : wlhbdp
@RequestMapping(value = "/login", produces = "application/json", method = RequestMethod.GET)
@ResponseBody
public ModelMap login(@RequestParam("username") String username, @RequestParam("preplacedword") String preplacedword) {
ModelMap model = new ModelMap();
// 查询用户数据
User user = new User(username, preplacedword);
ModelMap query = userService.login(user);
if (Boolean.parseBoolean(query.get("result").toString())) {
model.addAttribute("success", true);
model.addAttribute("user", query.get("user"));
} else {
model.addAttribute("success", false);
model.addAttribute("msg", query.get("msg"));
}
return model;
}
19
View Source File : ProductController.java
License : GNU General Public License v3.0
Project Creator : wlhbdp
License : GNU General Public License v3.0
Project Creator : wlhbdp
/**
* 模糊查询商品
* @param sql
* @return
*/
@RequestMapping(value = "/search", produces = "application/json", method = RequestMethod.GET)
@ResponseBody
public ModelMap queryProductInfo(@RequestParam("sql") String sql) {
ModelMap model = new ModelMap();
try {
model.addAttribute("success", true);
model.addAttribute("products", recommendService.getProductBySql(sql));
} catch (Exception e) {
e.printStackTrace();
model.addAttribute("success", false);
model.addAttribute("msg", e.getMessage());
}
return model;
}
19
View Source File : ProductController.java
License : GNU General Public License v3.0
Project Creator : wlhbdp
License : GNU General Public License v3.0
Project Creator : wlhbdp
/**
* 将评分数据发送到 kafka 'rating' Topic
* @param productId
* @param score
* @param userId
* @return
*/
@RequestMapping(value = "/rate/{productId}", produces = "application/json", method = RequestMethod.GET)
@ResponseBody
public ModelMap queryProductInfo(@PathVariable("productId") int productId, @RequestParam("score") Double score, @RequestParam("userId") int userId) {
ModelMap model = new ModelMap();
try {
String msg = userId + "," + productId + "," + score + "," + System.currentTimeMillis() / 1000;
CustomKafkaProducer.produce(msg);
System.out.println(msg);
model.addAttribute("success", true);
model.addAttribute("message", "完成评分");
} catch (Exception e) {
e.printStackTrace();
model.addAttribute("success", false);
model.addAttribute("msg", e.getMessage());
}
return model;
}
19
View Source File : ProductController.java
License : GNU General Public License v3.0
Project Creator : wlhbdp
License : GNU General Public License v3.0
Project Creator : wlhbdp
/**
* 查询单个商品
* @param productId
* @return
*/
@RequestMapping(value = "/query/{productId}", produces = "application/json", method = RequestMethod.GET)
@ResponseBody
public ModelMap queryProductInfo(@PathVariable("productId") int productId) {
ModelMap model = new ModelMap();
try {
model.addAttribute("success", true);
model.addAttribute("products", recommendService.getProductEnreplacedy(productId));
} catch (Exception e) {
e.printStackTrace();
model.addAttribute("success", false);
model.addAttribute("msg", e.getMessage());
}
return model;
}
19
View Source File : LogController.java
License : Apache License 2.0
Project Creator : wayn111
License : Apache License 2.0
Project Creator : wayn111
@RequestMapping("/detail/{id}")
@GetMapping
public String detail(ModelMap map, @PathVariable("id") String id) {
OperLog operLog = logService.getById(id);
String browserName = UserAgentUtils.getBrowserName(operLog.getAgent());
String osName = UserAgentUtils.getOsName(operLog.getAgent());
operLog.setAgent(browserName + "\t" + osName);
map.addAttribute("log", operLog);
return PREFIX + "/detail";
}
19
View Source File : LogController.java
License : MIT License
Project Creator : wayn111
License : MIT License
Project Creator : wayn111
@RequestMapping("/detail/{id}")
@GetMapping
public String detail(ModelMap map, @PathVariable("id") String id) {
map.addAttribute("log", logService.detail(id));
return PREFIX + "/detail";
}
19
View Source File : ConfigController.java
License : MIT License
Project Creator : wayn111
License : MIT License
Project Creator : wayn111
@RequiresPermissions("sys:config:edit")
@GetMapping("/edit/{id}")
public String edit(ModelMap modelMap, @PathVariable("id") Long id) {
Config config = configService.getById(id);
modelMap.put("config", config);
modelMap.addAttribute("sysBuildIn", dictService.selectDictsValueByType("sysBuildIn"));
return PREFIX + "/edit";
}
19
View Source File : LoginController.java
License : MIT License
Project Creator : wayn111
License : MIT License
Project Creator : wayn111
@GetMapping("/login")
public String login(ModelMap model) {
model.addAttribute("sysName", configService.getValueByKey("sys.name"));
model.addAttribute("sysFooter", configService.getValueByKey("sys.footer.copyright"));
return PREFIX + "/login";
}
19
View Source File : JobController.java
License : MIT License
Project Creator : wayn111
License : MIT License
Project Creator : wayn111
@RequiresPermissions("quartz:job:add")
@GetMapping("/add")
public String add(ModelMap modelMap) {
modelMap.addAttribute("misfirePolicys", dictService.selectDictsValueByType("misfirePolicy"));
return PREFIX + "/add";
}
19
View Source File : JobController.java
License : MIT License
Project Creator : wayn111
License : MIT License
Project Creator : wayn111
@RequiresPermissions("quartz:job:edit")
@GetMapping("/{option}/{id}")
public String edit(ModelMap modelMap, @PathVariable("option") String option, @PathVariable("id") Long id) {
Job job = jobService.getById(id);
modelMap.put("job", job);
modelMap.addAttribute("misfirePolicys", dictService.selectDictsValueByType("misfirePolicy"));
return PREFIX + "/" + option;
}
19
View Source File : NotifyRecordController.java
License : MIT License
Project Creator : wayn111
License : MIT License
Project Creator : wayn111
@RequiresPermissions("oa:notifyRecord:list")
@GetMapping
public String NotifyRecordIndex(ModelMap modelMap) {
modelMap.addAttribute("users", userService.selectUser2JsonObj());
return PREFIX + "/notifyRecord";
}
19
View Source File : NotifyController.java
License : MIT License
Project Creator : wayn111
License : MIT License
Project Creator : wayn111
@RequiresPermissions("oa:notify:list")
@GetMapping
public String NotifyIndex(ModelMap modelMap) {
modelMap.addAttribute("users", userService.selectUser2JsonObj());
return PREFIX + "/notify";
}
19
View Source File : FreeMarkerViewTests.java
License : MIT License
Project Creator : Vip-Augus
License : MIT License
Project Creator : Vip-Augus
// gh-22754
@Test
public void subscribeWithoutDemand() {
ZeroDemandResponse response = new ZeroDemandResponse();
ServerWebExchange exchange = new DefaultServerWebExchange(MockServerHttpRequest.get("/path").build(), response, new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
FreeMarkerView view = new FreeMarkerView();
view.setConfiguration(this.freeMarkerConfig);
view.setUrl("test.ftl");
ModelMap model = new ExtendedModelMap();
model.addAttribute("hello", "hi FreeMarker");
view.render(model, null, exchange).subscribe();
response.cancelWrite();
response.checkForLeaks();
}
19
View Source File : LoginController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@GetMapping("demo2")
public String demo2(HttpServletRequest request, ModelMap map) {
Cookie[] cookies = request.getCookies();
if (!Arrays.isNullOrEmpty(cookies)) {
for (Cookie cookie : cookies) {
if ("sso-domain".equals(cookie.getName())) {
Map<String, String> params = new HashMap<>();
params.put("cookieName", cookie.getName());
params.put("cookieValue", cookie.getValue());
String result = doGet("http://www.check.com:8081/check", params);
if ("1".equals(result)) {
return "demo2";
}
}
}
}
map.addAttribute("gotoUrl", "http://www.demo2.com:8081/demo2");
map.addAttribute("path", "demo2");
return "login";
}
19
View Source File : LoginController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@PostMapping("demo2/login")
public String demo2Login(String username, String preplacedword, ModelMap map) {
Map<String, String> params = new HashMap<>();
params.put("username", username);
params.put("preplacedword", preplacedword);
String result = doGet("http://www.check.com:8081/login", params);
if ("1".equals(result)) {
List<String> urls = java.util.Arrays.asList("http://www.demo1.com:8081/demo1/add", "http://www.demo2.com:8081/demo2/add");
map.addAttribute("urls", urls);
return "demo2";
}
return "login";
}
19
View Source File : LoginController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@GetMapping("demo1")
public String demo1(HttpServletRequest request, ModelMap map) {
Cookie[] cookies = request.getCookies();
if (!Arrays.isNullOrEmpty(cookies)) {
for (Cookie cookie : cookies) {
if ("sso-domain".equals(cookie.getName())) {
Map<String, String> params = new HashMap<>();
params.put("cookieName", cookie.getName());
params.put("cookieValue", cookie.getValue());
String result = doGet("http://www.check.com:8081/check", params);
if ("1".equals(result)) {
return "demo1";
}
}
}
}
map.addAttribute("gotoUrl", "http://www.demo1.com:8081/demo1");
map.addAttribute("path", "demo1");
return "login";
}
19
View Source File : LoginController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@PostMapping("demo1/login")
public String demo1Login(String username, String preplacedword, ModelMap map) {
Map<String, String> params = new HashMap<>();
params.put("username", username);
params.put("preplacedword", preplacedword);
String result = doGet("http://www.check.com:8081/login", params);
if ("1".equals(result)) {
List<String> urls = java.util.Arrays.asList("http://www.demo1.com:8081/demo1/add", "http://www.demo2.com:8081/demo2/add");
map.addAttribute("urls", urls);
return "demo1";
}
return "login";
}
19
View Source File : LoginController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@GetMapping("demo2")
public String demo2(HttpServletRequest request, ModelMap map) {
Cookie[] cookies = request.getCookies();
if (!Arrays.isNullOrEmpty(cookies)) {
for (Cookie cookie : cookies) {
if ("sso-domain".equals(cookie.getName())) {
String result = doGet("http://check.x.com:8081/check", cookie.getName(), cookie.getValue());
if ("1".equals(result)) {
return "demo2";
}
}
}
}
map.addAttribute("gotoUrl", "http://demo2.x.com:8081/demo2");
return "login";
}
19
View Source File : LoginController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@GetMapping("demo1")
public String demo1(HttpServletRequest request, ModelMap map) {
Cookie[] cookies = request.getCookies();
if (!Arrays.isNullOrEmpty(cookies)) {
for (Cookie cookie : cookies) {
if ("sso-domain".equals(cookie.getName())) {
String result = doGet("http://check.x.com:8081/check", cookie.getName(), cookie.getValue());
if ("1".equals(result)) {
return "demo1";
}
}
}
}
map.addAttribute("gotoUrl", "http://demo1.x.com:8081/demo1");
return "login";
}
19
View Source File : HelloController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@GetMapping("/{name}")
public String hello(@PathVariable String name) {
ModelMap map = new ModelMap();
map.addAttribute("name", name);
return "index";
}
19
View Source File : HelloController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
@GetMapping("/{name}")
public String hello(@PathVariable("name") String name) {
ModelMap map = new ModelMap();
map.addAttribute("name", name);
return "index";
}
19
View Source File : HelloController.java
License : Apache License 2.0
Project Creator : ukihsoroy
License : Apache License 2.0
Project Creator : ukihsoroy
// 配置URL映射
@GetMapping("/hello")
public String hello(ModelMap model) {
model.addAttribute("user", new User("K.O", new Date()));
// 返回视图名称
return "hello";
}
19
View Source File : StudentController.java
License : Apache License 2.0
Project Creator : turoDog
License : Apache License 2.0
Project Creator : turoDog
/**
* 获取保存 student 表单
*/
@GetMapping(value = "/create")
public String createStudentForm(ModelMap map) {
map.addAttribute("student", new Student());
map.addAttribute("action", "create");
return "studentForm";
}
19
View Source File : StudentController.java
License : Apache License 2.0
Project Creator : turoDog
License : Apache License 2.0
Project Creator : turoDog
/**
* 获取学生信息列表
* @param map
* @return
*/
@GetMapping("/list")
public String findStudentList(ModelMap map) {
map.addAttribute("studentList", studentService.findStudentList());
return "studentList";
}
19
View Source File : StudentController.java
License : Apache License 2.0
Project Creator : turoDog
License : Apache License 2.0
Project Creator : turoDog
/**
* 根据 id 获取 student 表单,编辑后提交更新
* @param id
* @param map
* @return
*/
@GetMapping(value = "/update/{id}")
public String edit(@PathVariable Long id, ModelMap map) {
map.addAttribute("student", studentService.findStudentById(id));
map.addAttribute("action", "update");
return "studentForm";
}
19
View Source File : HomeController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/blog/services/1point3acres")
public String point3acres(ModelMap modelMap) {
modelMap.addAttribute("count", point3AcreService.countAcreInfo());
return "1point3acres";
}
19
View Source File : HomeController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/blog/services/leetcode")
public String leetcode(ModelMap modelMap) {
modelMap.addAttribute("count", leetcodeInfoService.countLeetcodeInfo());
return "leetcode";
}
19
View Source File : FrontDocController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping
public String docs(ModelMap modelMap) throws Exception {
// 最热模板数据
List<DocTemplate> docTemplates = docTemplateService.listHottestDocs(config.getLargePage());
modelMap.addAttribute("templates", batchTransferVO(docTemplates));
return "doc";
}
19
View Source File : FrontArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
// Todo: 重构一下
@GetMapping("/home")
public String main(ModelMap modelMap, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "0") int sortType, @RequestParam(defaultValue = "0") int categoryId) throws IOException, ServiceException {
// 主页数据
String json;
if (categoryId == 0)
json = HttpUtil.get(config.getUrl("/api/articles?page=" + page + "&sortType=" + sortType));
else
json = HttpUtil.get(config.getUrl("/api/articles/category_id/" + categoryId + "?page=" + page + "&sortType=" + sortType));
json = JsonUtil.getDataAndCheck(json);
Page<ArticleVO> holder = JsonUtil.string2Bean(json, Page.clreplaced);
modelMap.addAttribute("page", holder.getPage());
modelMap.addAttribute("maxPage", holder.getMaxPage());
modelMap.addAttribute("data", holder.getData());
// 最热文章数据
json = HttpUtil.get(config.getUrl("/api/articles/popular"));
json = JsonUtil.getDataAndCheck(json);
List<ArticleVO> articleVOS = JsonUtil.string2Bean(json, List.clreplaced);
modelMap.addAttribute("popular_data", articleVOS);
// 分类数据
json = HttpUtil.get(config.getUrl("/api/categories"));
json = JsonUtil.getDataAndCheck(json);
List<CategoryVO> categoryVOS = JsonUtil.string2Bean(json, List.clreplaced);
modelMap.addAttribute("category_data", categoryVOS);
modelMap.addAttribute("category_id", categoryId);
modelMap.addAttribute("sort_type", sortType);
return "main";
}
19
View Source File : FrontArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/posts/{id}")
public String posts(ModelMap modelMap, @PathVariable int id) throws IOException, ServiceException {
// 文章数据
String json = HttpUtil.get(config.getUrl("/api/articles/" + id));
json = JsonUtil.getDataAndCheck(json);
ArticleVO articleVO = JsonUtil.string2Bean(json, ArticleVO.clreplaced);
modelMap.addAttribute("article", articleVO);
// 最热文章数据
json = HttpUtil.get(config.getUrl("/api/articles/popular"));
json = JsonUtil.getDataAndCheck(json);
List<ArticleVO> articleVOS = JsonUtil.string2Bean(json, List.clreplaced);
modelMap.addAttribute("popular_data", articleVOS);
// 分类数据
json = HttpUtil.get(config.getUrl("/api/categories"));
json = JsonUtil.getDataAndCheck(json);
List<CategoryVO> categoryVOS = JsonUtil.string2Bean(json, List.clreplaced);
modelMap.addAttribute("category_data", categoryVOS);
return "post";
}
19
View Source File : BackCronJobController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/new")
public String newJob(ModelMap modelMap) {
// 草稿数量
long cnt = articleService.countArticleByStatus(Article.Status.OFFLINE);
modelMap.addAttribute("draft_cnt", cnt);
return "back_new_cronjob";
}
19
View Source File : BackCronJobController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/config/{jobId}")
public String editJob(ModelMap modelMap, @PathVariable String jobId) throws ServiceException {
Job job = jobService.getJobByJobId(jobId);
JobVO jobVO = new JobVO(job);
modelMap.addAttribute("job", jobVO);
// 草稿数量
long cnt = articleService.countArticleByStatus(Article.Status.OFFLINE);
modelMap.addAttribute("draft_cnt", cnt);
modelMap.addAttribute("jobName", job.getName());
return "back_edit_cronjob";
}
19
View Source File : BackArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/categories")
public String categories(ModelMap modelMap) throws IOException, ServiceException {
// 分组数据
String json = HttpUtil.get(config.getUrl("/api/categories"));
json = JsonUtil.getDataAndCheck(json);
List<CategoryVO> categories = JsonUtil.string2List(json, CategoryVO.clreplaced);
modelMap.addAttribute("categories", categories);
// 草稿数量
json = HttpUtil.get(config.getUrl("/api/articles/count/0"));
json = JsonUtil.getDataAndCheck(json);
modelMap.addAttribute("draft_cnt", json);
return "back_categories";
}
19
View Source File : BackArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping
public String articles(ModelMap modelMap, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "0") int sortType, @RequestParam(defaultValue = "0") int categoryId) throws IOException, ServiceException {
// 文章列表数据
String json;
if (categoryId == 0)
json = HttpUtil.get(config.getUrl("/api/articles?page=" + page + "&sortType=" + sortType));
else
json = HttpUtil.get(config.getUrl("/api/articles/category_id/" + categoryId + "?page=" + page + "&sortType=" + sortType));
json = JsonUtil.getDataAndCheck(json);
Page<ArticleVO> holder = JsonUtil.string2Bean(json, Page.clreplaced);
modelMap.addAttribute("page", holder.getPage());
modelMap.addAttribute("maxPage", holder.getMaxPage());
modelMap.addAttribute("articles", holder.getData());
// 标识当前页面显示状态 0-普通 1-通过名字搜索
modelMap.addAttribute("status", 0);
// 草稿数量
json = HttpUtil.get(config.getUrl("/api/articles/count/0"));
json = JsonUtil.getDataAndCheck(json);
modelMap.addAttribute("draft_cnt", json);
// 分组数据
json = HttpUtil.get(config.getUrl("/api/categories"));
json = JsonUtil.getDataAndCheck(json);
List<CategoryVO> categories = JsonUtil.string2List(json, CategoryVO.clreplaced);
modelMap.addAttribute("categories", categories);
modelMap.addAttribute("category_id", categoryId);
return "back_article_management";
}
19
View Source File : BackArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/drafts")
public String drafts(ModelMap modelMap, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "0") int sortType) throws IOException, ServiceException {
// 搜索文章列表数据
String json = HttpUtil.get(config.getUrl("/api/articles/drafts?page=" + page + "&sortType=" + sortType));
json = JsonUtil.getDataAndCheck(json);
Page<ArticleVO> holder = JsonUtil.string2Bean(json, Page.clreplaced);
modelMap.addAttribute("page", holder.getPage());
modelMap.addAttribute("maxPage", holder.getMaxPage());
modelMap.addAttribute("articles", holder.getData());
// 草稿数量
json = HttpUtil.get(config.getUrl("/api/articles/count/0"));
json = JsonUtil.getDataAndCheck(json);
modelMap.addAttribute("draft_cnt", json);
return "back_drafts";
}
19
View Source File : BackArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/drafts/{id}")
public String draft(ModelMap modelMap, @PathVariable int id, @RequestParam(defaultValue = "1") int page) throws IOException, ServiceException {
// 草稿数据
String json = HttpUtil.get(config.getUrl("/api/articles/" + id));
json = JsonUtil.getDataAndCheck(json);
ArticleVO articleVO = JsonUtil.string2Bean(json, ArticleVO.clreplaced);
modelMap.addAttribute("article", articleVO);
// 图片列表数据
json = HttpUtil.get(config.getUrl("/api/images/?page=" + page));
json = JsonUtil.getDataAndCheck(json);
Page<Image> holder = JsonUtil.string2Bean(json, Page.clreplaced);
modelMap.addAttribute("page", holder.getPage());
modelMap.addAttribute("maxPage", holder.getMaxPage());
modelMap.addAttribute("images", holder.getData());
// preface 数据
if (articleVO.getPreface() != null) {
ImageVO imageVO = new ImageVO(imageService.getImageBySlimUrl(articleVO.getPreface().replaceAll(config.getStorageHost(), "")));
imageVO.setUrl(config.getStorageHost() + imageVO.getUrl());
imageVO.setThumbUrl(config.getStorageHost() + imageVO.getThumbUrl());
imageVO.setSlimUrl(config.getStorageHost() + imageVO.getSlimUrl());
modelMap.addAttribute("image_preface", imageVO);
}
// 分组数据
json = HttpUtil.get(config.getUrl("/api/categories"));
json = JsonUtil.getDataAndCheck(json);
List<CategoryVO> categories = JsonUtil.string2List(json, CategoryVO.clreplaced);
modelMap.addAttribute("categories", categories);
// 草稿数量
json = HttpUtil.get(config.getUrl("/api/articles/count/0"));
json = JsonUtil.getDataAndCheck(json);
modelMap.addAttribute("draft_cnt", json);
return "back_new_article";
}
19
View Source File : BackArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/new_article")
public String newArticle(ModelMap modelMap, @RequestParam(defaultValue = "1") int page) throws IOException, ServiceException {
// 图片列表数据
String json = HttpUtil.get(config.getUrl("/api/images/?page=" + page));
json = JsonUtil.getDataAndCheck(json);
Page<Image> holder = JsonUtil.string2Bean(json, Page.clreplaced);
modelMap.addAttribute("page", holder.getPage());
modelMap.addAttribute("maxPage", holder.getMaxPage());
modelMap.addAttribute("images", holder.getData());
// 分组数据
json = HttpUtil.get(config.getUrl("/api/categories"));
json = JsonUtil.getDataAndCheck(json);
List<CategoryVO> categories = JsonUtil.string2List(json, CategoryVO.clreplaced);
modelMap.addAttribute("categories", categories);
// 草稿数量
json = HttpUtil.get(config.getUrl("/api/articles/count/0"));
json = JsonUtil.getDataAndCheck(json);
modelMap.addAttribute("draft_cnt", json);
return "back_new_article";
}
19
View Source File : BackArticleController.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@GetMapping("/{name}")
public String articles(ModelMap modelMap, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "0") int sortType, @PathVariable String name) throws IOException, ServiceException {
// 搜索文章列表数据
name = URLEncoder.encode(name, "UTF-8");
String json = HttpUtil.get(config.getUrl("/api/articles/name/" + name + "?page=" + page + "&sortType=" + sortType));
json = JsonUtil.getDataAndCheck(json);
Page<ArticleVO> holder = JsonUtil.string2Bean(json, Page.clreplaced);
modelMap.addAttribute("page", holder.getPage());
modelMap.addAttribute("maxPage", holder.getMaxPage());
modelMap.addAttribute("articles", holder.getData());
// 标识当前页面显示状态 0-普通 1-通过名字搜索
modelMap.addAttribute("status", 1);
// 草稿数量
json = HttpUtil.get(config.getUrl("/api/articles/count/0"));
json = JsonUtil.getDataAndCheck(json);
modelMap.addAttribute("draft_cnt", json);
// 分组数据
json = HttpUtil.get(config.getUrl("/api/categories"));
json = JsonUtil.getDataAndCheck(json);
List<CategoryVO> categories = JsonUtil.string2List(json, CategoryVO.clreplaced);
modelMap.addAttribute("categories", categories);
modelMap.addAttribute("category_id", 0);
name = URLDecoder.decode(name, "UTF-8");
modelMap.addAttribute("replacedle", name);
return "back_article_management";
}
19
View Source File : AspectHandler.java
License : MIT License
Project Creator : toxicaker
License : MIT License
Project Creator : toxicaker
@Before("viewOutput()")
public void viewBefore(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
for (Object obj : args) {
if (obj instanceof ModelMap) {
ModelMap map = (ModelMap) obj;
if (config.getDomain() != null && !config.getDomain().equals("")) {
map.addAttribute("host", config.getHead() + config.getDomain());
} else {
map.addAttribute("host", config.getHead() + config.getHost() + ":" + config.getPort());
}
}
}
}
19
View Source File : VisionController.java
License : Apache License 2.0
Project Creator : spring-cloud
License : Apache License 2.0
Project Creator : spring-cloud
@GetMapping("/extractText")
public ModelAndView extractText(String imageUrl, ModelMap map) {
String text = this.cloudVisionTemplate.extractTextFromImage(this.resourceLoader.getResource(imageUrl));
map.addAttribute("text", text);
map.addAttribute("imageUrl", imageUrl);
return new ModelAndView("result", map);
}
19
View Source File : FreeMarkerViewTests.java
License : Apache License 2.0
Project Creator : SourceHot
License : Apache License 2.0
Project Creator : SourceHot
// gh-22754
@Test
public void subscribeWithoutDemand() {
ZeroDemandResponse response = new ZeroDemandResponse();
ServerWebExchange exchange = new DefaultServerWebExchange(MockServerHttpRequest.get("/path").build(), response, new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver());
FreeMarkerView view = new FreeMarkerView();
view.setApplicationContext(this.context);
view.setConfiguration(this.freeMarkerConfig);
view.setUrl("test.ftl");
ModelMap model = new ExtendedModelMap();
model.addAttribute("hello", "hi FreeMarker");
view.render(model, null, exchange).subscribe();
response.cancelWrite();
response.checkForLeaks();
}
19
View Source File : VulnerabilityDetailController.java
License : Mozilla Public License 2.0
Project Creator : secdec
License : Mozilla Public License 2.0
Project Creator : secdec
@RequestMapping(value = "/{vulnerabilityId}/defect", method = RequestMethod.GET)
public String viewDefect(@PathVariable("appId") int appId, @PathVariable("orgId") int orgId, @PathVariable("vulnerabilityId") int vulnerabilityId, ModelMap model) {
if (!PermissionUtils.isAuthorized(Permission.READ_ACCESS, orgId, appId)) {
return "403";
}
Vulnerability vulnerability = vulnerabilityService.loadVulnerability(vulnerabilityId);
checkResourceNotFound(vulnerability, vulnerabilityId, appId);
if (vulnerability.getDefect() == null) {
log.warn("The requested Vulnerability did not have an replacedociated Defect, returning to the Vulnerability page.");
return "redirect:/organizations/" + orgId + "/applications/" + appId + "/vulnerabilities/" + vulnerabilityId;
}
model.addAttribute("defect", vulnerability.getDefect());
return "applications/defects";
}
19
View Source File : VulnerabilityDetailController.java
License : Mozilla Public License 2.0
Project Creator : secdec
License : Mozilla Public License 2.0
Project Creator : secdec
@RequestMapping(value = "/{vulnerabilityId}/mergeFindings", method = RequestMethod.GET)
public String mergeFinding(@PathVariable("vulnerabilityId") int vulnerabilityId, ModelMap model, @PathVariable("appId") int appId, @PathVariable("orgId") int orgId) {
if (!PermissionUtils.isAuthorized(Permission.CAN_MODIFY_VULNERABILITIES, orgId, appId)) {
return "403";
}
Vulnerability vulnerability = vulnerabilityService.loadVulnerability(vulnerabilityId);
checkResourceNotFound(vulnerability, vulnerabilityId, appId);
if (vulnerability.getFindings() != null && vulnerability.getFindings().size() != 0 && vulnerability.getFindings().size() != 1) {
List<Finding> findings = vulnerability.getFindings();
model.addAttribute(findings);
}
model.addAttribute(vulnerability);
model.addAttribute("isEnterprise", EnterpriseTest.isEnterprise());
return "/applications/vulnerability";
}
19
View Source File : UsersController.java
License : Mozilla Public License 2.0
Project Creator : secdec
License : Mozilla Public License 2.0
Project Creator : secdec
private String indexInner(ModelMap model, HttpServletRequest request, String defaultTab) {
model.addAttribute("ldap_plugin", EnterpriseTest.isEnterprise());
model.addAttribute("startingTab", defaultTab);
model.addAttribute("user", new User());
model.addAttribute("successMessage", ControllerUtils.getSuccessMessage(request));
model.addAttribute("errorMessage", ControllerUtils.getErrorMessage(request));
if (EnterpriseTest.isEnterprise()) {
model.addAttribute("accessControlMapModel", new AccessControlMapModel());
model.addAttribute("group", new Group());
model.addAttribute("editGroup", new Group());
model.addAttribute("role", new Role());
model.addAttribute("editRole", new Role());
return "config/users/enterprise/index";
} else {
return "config/users/community/index";
}
}
19
View Source File : JobStatusController.java
License : Mozilla Public License 2.0
Project Creator : secdec
License : Mozilla Public License 2.0
Project Creator : secdec
@RequestMapping(value = "/all", method = RequestMethod.GET)
public String showAllJobs(ModelMap model) {
model.addAttribute(jobStatusService.loadAll());
model.addAttribute("viewAll", true);
return "config/jobs";
}
19
View Source File : AddSurveyController.java
License : Mozilla Public License 2.0
Project Creator : secdec
License : Mozilla Public License 2.0
Project Creator : secdec
@RequestMapping(params = "surveys/save", method = RequestMethod.POST)
public String saveResults(@PathVariable("orgId") int orgId, @ModelAttribute SurveyResult surveyResult, ModelMap model) {
if (!PermissionUtils.isAuthorized(Permission.READ_ACCESS, orgId, null)) {
return "403";
}
if (surveyResult.isSubmitted()) {
log.error("Cannot save already submitted survey");
return "redirect:/organizations/" + orgId + "/surveys/" + surveyResult.getId();
}
if (surveyResult.getSurveyAnswers() != null) {
for (SurveyAnswer answer : surveyResult.getSurveyAnswers()) {
answer.setSurveyResult(surveyResult);
}
}
if (surveyResult.getSurveyRankings() != null) {
for (SurveyRanking ranking : surveyResult.getSurveyRankings()) {
ranking.setSurveyResult(surveyResult);
}
}
String userName = SecurityContextHolder.getContext().getAuthentication().getName();
surveyResult.setUser(userName);
surveyResult.setOrganization(organizationService.loadById(orgId));
surveyService.saveOrUpdateResult(surveyResult);
model.addAttribute("saveConfirm", true);
return "surveys/form";
}
19
View Source File : AddSurveyController.java
License : Mozilla Public License 2.0
Project Creator : secdec
License : Mozilla Public License 2.0
Project Creator : secdec
@RequestMapping(method = RequestMethod.GET)
public String selectSurvey(@PathVariable("orgId") int orgId, ModelMap model) {
Organization organization = organizationService.loadById(orgId);
if (organization != null) {
if (!PermissionUtils.isAuthorized(Permission.READ_ACCESS, orgId, null)) {
return "403";
}
String userName = SecurityContextHolder.getContext().getAuthentication().getName();
SurveyResult surveyResult = new SurveyResult();
surveyResult.setUser(userName);
surveyResult.setOrganization(organization);
model.addAttribute(surveyResult);
model.addAttribute(surveyService.loadAll());
surveyResult.setSurvey(surveyService.loadSurvey(1));
surveyResult.generateEmptyAnswers();
return "surveys/form";
} else {
log.warn(ResourceNotFoundException.getLogMessage("Organization", orgId));
throw new ResourceNotFoundException();
}
}
See More Examples