2010-04-07 81 views
0

Struts 2是否具有完整的简单登录任务解决方案? 我在struts.xml中简单声明:Struts 2安全性

<package namespace="/protected" name="manager" extends="struts-default" > 

    <interceptors> 
     <interceptor-stack name="secure"> 
      <interceptor-ref name="roles"> 
       <param name="allowedRoles">registered</param> 
      </interceptor-ref> 
     </interceptor-stack> 
    </interceptors> 
    <default-action-ref name="pindex"/> 

    <action name="pindex" > 
     <interceptor-ref name="completeStack"/> 
     <interceptor-ref name="secure"/> 
     <result>protected/index.html</result> 
    </action> 
</package> 

访问这个资源将只显示(禁止403)。所以,我应该做的下一步:

  1. 添加登录页面(web.xml上的非标准Tomcat的声明与<登录,配置>不工作)?
  2. 提供安全往返。我需要编写自己的servlet还是存在struts2解决方案?

在此先感谢!

回答

0

您不能在"pindex"操作中添加“错误”或“输入”结果吗?如

<result name="error">public/error.html</result> 
+0

没有什么变化。 public/error.html永远不会被调用 – Dewfy 2010-04-07 19:26:07

+0

您是否尝试过“输入”结果? ' public/error.html' – 2010-04-07 20:35:23

+0

他们都是错误的输入 – Dewfy 2010-04-07 21:10:37