我有一个 JSP 页面,它从我的 Hibernate 项目中的控制器调用方法
这是我在 JSP 页面中的一些代码:
...
<jsp:useBean id="acl" scope="request" class="com.angelina.token.controller.AccessControlListsController"/>
...
<c:if test="<c:if test="${acl.allowView(session,7)}">">
<a style="font-size:12px;" href="<c:url value="/admin/account/"/>">Account Balance</a>
</c:if>
...
这是我的一些控制器
...
@Autowired
private AccessControlListsService aclService;
@Autowired
private UsersService usersService;
...
@RequestMapping(value="")
@ResponseBody
public boolean allowView(HttpSession session, Integer permissionId) throws Exception {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
String userName = auth.getName();
Users users = usersService.findByUserName(userName).get(0);
Integer roleId = users.getRoles().getId();
Boolean status = aclService.getByRoleIdAndPermissionId(roleId, permissionId).getCanView();
return status;
}
...
usersService
allowView(HttpSession session, Integer permissionId)
是一个服务对象,当我从 JSP 页面调用方法时,usersService
总是返回 null。
有没有人知道我应该怎么做才能使我的对象服务不返回 null?
我真的很感激任何帮助。