1、应用的意义

      

在某些应用下,如果Action类执行的功能比较重要,可以对该Action类进行授权利以实现只有特定角色的用户能够访问,此时可以在struts-config.xml文件中进行配置

 

2、在struts-config.xml文件中进行配置

 

<action-mappings>

           <actionpath="/BookInfo/indexLoginURI"   type="netbook.IndexLoginAction"    name="IndexLoginForm"

                  scope="request"     validate="true"      input="/index.jsp" roles="admin">

                  <forwardname="loginSuccess" path="/BookInfo/ShowBookInfo.jsp" />

                     <forwardname="loginFailure" path="/BookInfo/gotoIndex.htm"/>      

           </action>

 </action-mappings>

 

3、 问该Action

 

如果访问者不是admin 角色的用户,此时将出现如下的错误

Tomcat对Struts中的Action进行授权利

相关文章:

  • 2021-09-21
  • 2022-01-19
  • 2021-09-03
  • 2021-08-30
  • 2021-11-19
  • 2021-06-30
  • 2022-12-23
猜你喜欢
  • 2021-05-17
  • 2022-01-09
  • 2021-10-31
  • 2022-01-04
  • 2023-03-10
  • 2022-12-23
相关资源
相似解决方案