English 中文(简体)
习俗错误 页 次 3 + Permissions
原标题:custom error Page + spring security 3 + hasPermission

how to show a custom error page when user fails to see a page (when do not have specific permission) after getting HTTP 500 -

org. Sandframework.security.access.AccessDeniedException: 不准进入

Exception from custom hasPermission() method.

You can check my previous question here to see my code.

最佳回答

In your struts2 config file you can configure global exceptions like

<global-exception-mappings>
    <exception-mapping exception="org.springframework.security.access.AccessDeniedException" result="securityerror" />
     <exception-mapping exception="java.lang.Exception" result="error" />
   </global-exception-mappings>

  <global-results>
        <result name="securityerror">/securityerror.jsp</result>
    <result name="error">/error.jsp</result>
   </global-results>

如果你发现细微的例外情况,处理你可以确定的行动等级,则会达到申请水平。

<action name="actionspecificexception" class="org.apache.struts.register.action.Register" method="throwSecurityException">
     <exception-mapping exception="org.springframework.security.access.AccessDeniedException" 
          result="login" />
      <result>/register.jsp</result>
      <result name="login">/login.jsp</result>
   </action>

因此,这取决于你们选择如何混淆。 详见下文。

rel=“nofollow” 特殊处理

我建议不要把一切例外当作一个 raw子,更好地制造你自己的例外,在其中总结这种例外情况,将有助于你更好地组织你的法典。

Hope this will help you.

问题回答

暂无回答




相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签