论坛首页 Java企业应用论坛

在 method 里面 根据用户 转不同页面 如何实现

浏览 1339 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2014-05-27  
我在代码后面添加了如下代码,但是user值不能载入。请问什么方法可以对已经登陆的user值进行分析,然后进行下一步判断。谢谢了。     
String result="editRulePart";
    String role = user.getRole();
if(role.equals("ROLE_UPD_HIGH"))
result = "editRule";
if(role.equals("ROLE_UPD_MED"))
result =  "editRulePart";
return result;

原代码是一个方法。我想添加 根据用户不同转到不同页面。不是登陆就转的那种。

/*** EDIT RULE PAGE ***/
@RequestMapping("/editrule/{ruleId}")
public String editRule(
ModelMap map,
@PathVariable("ruleId") Integer ruleId,
@RequestParam(value="action",required=false) String action) {

logger.info("edit rule page called (\"/editrule\")");
Rule rule = ruleService.findRuleById(ruleId);
if(rule == null) {
logger.warn("no found with id = "+ruleId);
return "error";
}
else {
map.addAttribute("action", "updaterule");

List<Enrichment> enrichmentList = enrichmentService.listEnrichment();
map.addAttribute("enrichments", enrichmentList);
List<Endpoint> endpointList = endpointService.listEndpoint();
map.addAttribute("endpoints", endpointList);
List<Tag> tagList = tagService.listTag();
map.addAttribute("tagList", tagList);

RuleFormWrap ruleFormWrap = new RuleFormWrap();
ruleFormWrap.setRule(rule);
ruleFormWrap.setAction(action);

String filterType;
if(rule.getFilter() != null) {
filterType = rule.getFilter().getClass().getSimpleName();
ruleFormWrap.getFilters().put(filterType, rule.getFilter());
//for(Filter f : ruleFormWrap.getFilters().values()) f.setId(rule.getFilter().getId());
}
else {
filterType = "none";
}
ruleFormWrap.setSelectedFilter(filterType);
map.addAttribute("ruleFormWrap", ruleFormWrap);
String result="editRulePart";
    String role = user.getRole();
if(role.equals("ROLE_UPD_HIGH"))
result = "editRule";
if(role.equals("ROLE_UPD_MED"))
result =  "editRulePart";
return result;
}
}
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics