shiro JSP使用标签报错

在JSP页面使用shiro标签报错,要怎么改?求大神指点
java.lang.IllegalArgumentException: Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.
org.apache.shiro.authz.permission.WildcardPermission.setParts(WildcardPermission.java:151)
org.apache.shiro.authz.permission.WildcardPermission.(WildcardPermission.java:142)
org.apache.shiro.authz.permission.WildcardPermission.(WildcardPermission.java:138)
org.apache.shiro.authz.permission.WildcardPermissionResolver.resolvePermission(WildcardPermissionResolver.java:41)
org.apache.shiro.realm.AuthorizingRealm.resolvePermissions(AuthorizingRealm.java:433)
org.apache.shiro.realm.AuthorizingRealm.getPermissions(AuthorizingRealm.java:409)
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:466)
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:462)
org.apache.shiro.realm.AuthorizingRealm.isPermitted(AuthorizingRealm.java:457)
org.apache.shiro.authz.ModularRealmAuthorizer.isPermitted(ModularRealmAuthorizer.java:223)
org.apache.shiro.mgt.AuthorizingSecurityManager.isPermitted(AuthorizingSecurityManager.java:113)
org.apache.shiro.subject.support.DelegatingSubject.isPermitted(DelegatingSubject.java:158)
org.apache.shiro.web.tags.PermissionTag.isPermitted(PermissionTag.java:66)
org.apache.shiro.web.tags.HasPermissionTag.showTagBody(HasPermissionTag.java:32)
org.apache.shiro.web.tags.PermissionTag.onDoStartTag(PermissionTag.java:57)
org.apache.shiro.web.tags.SecureTag.doStartTag(SecureTag.java:53)
org.apache.jsp.success_jsp._jspx_meth_shiro_005fhasPermission_005f0(success_jsp.java:205)
org.apache.jsp.success_jsp._jspService(success_jsp.java:122)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)

index.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

Hello World!

<form action="/login.do" method="post">
    <table>
        <tr>
            <td>账号:</td>
            <td><input name="username" value="${users.username}"/></td>
        </tr>
        <tr>
            <td>密码:</td>
            <td><input type="password" name="password" value="${users.password}"/></td><br/>
            <td><input type="submit" value="login"/><span style="font-size: 12px;color: red">${error}</span></td>
        </tr>

    </table>
</form>


登录成功之后的页面success.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>



Insert title here


${info }欢迎你


欢迎有admin角色的用户!shiro:principal/
/shiro:hasRole

欢迎有student:create权限的用户!shiro:principal/
/shiro:hasPermission

controller
@Controller
public class UsersController {

@Autowired
private UsersService usersService;

@RequestMapping("/login")
public String login(Model model,Users users){
    Subject subject = SecurityUtils.getSubject();
    UsernamePasswordToken token = new UsernamePasswordToken(users.getUsername(),users.getPassword());
    try {
        subject.login(token);

// Model model1 = (Model) subject.getSession();
// model1.addAttribute("info","welcome to");
// Session session = subject.getSession();
// session.setAttribute("info","Welcome To Shiro");
return "redirect:/success.jsp";
}catch (Exception e) {
e.printStackTrace();
model.addAttribute("users",users);
model.addAttribute("error","用户名或密码错误");
return "index";
}
}

}

查看全部
qq_28454325
qq_28454325
2016/05/25 05:50
  • spring
  • java
  • shiro
  • mybatis
  • 点赞
  • 收藏
  • 回答
    私信

3个回复