我寫了一個控制器導航到名爲accessDenied.jsp的頁面。 我使用Spring 4.3.6版本爲什麼在spring中返回ModelAndView提示下載視圖名稱的.json?
@Controller
public class BatchAccessDeniedController {
static String ERRORPAGE = "accessDenied";
public static final Logger LOG = Logger.getLogger(BatchAccessDeniedController.class);
@RequestMapping(value = "/accessDenied" , method = RequestMethod.GET)
public ModelAndView accessDenied(Principal user, ModelAndView modelAndView) {
//Log the user who tried to access the restricted resource
if (user != null) {
LOG.info(user.getName() + " you do not have permission to access this page!");
} else {
LOG.info("You do not have permission to access this page!");
}
modelAndView.setViewName(ERRORPAGE);
return modelAndView;
}
}
,一切工作正常與上面的代碼,直到我介紹Spring Batch的聯繫依賴,並在web.xml中批量管理配置爲波紋管
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/root-context.xml,
classpath*:/org/springframework/batch/admin/web/resources/webapp-config.xml,
classpath:/config/spring-ldap-servlet.xml
</param-value>
</context-param>
<!-- Filter for Spring Security LDAP -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>shallowEtagHeaderFilter</filter-name>
<filter-class>org.springframework.web.filter.ShallowEtagHeaderFilter</filter-class>
</filter>
<filter>
<filter-name>hiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>shallowEtagHeaderFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>hiddenHttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<servlet>
<servlet-name>runlauncher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/config/application-web-context.xml,
classpath*:/org/springframework/batch/admin/web/resources/servlet-config.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>runlauncher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- Invalidate user session after 15 minutes of inactivity -->
<session-config>
<session-timeout>15</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
批次管理依賴關係是如下面
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-admin-manager</artifactId>
<version>${spring.batch.admin}</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-admin-resources</artifactId>
<version>${spring.batch.admin}</version>
</dependency>
通過添加此,認爲來到BatchAccessDeniedController類的控制,它會提示給downl oad index.json文件。我不明白爲什麼它要求下載index.json文件而不是重定向到accessDenied.jsp頁面。另外我的配置是spring-ldap,其中index.jsp是用戶登錄後的默認頁面。
我懷疑是導致問題的批量管理用戶界面出了問題。如果有人遇到類似的問題,請幫我解決這個問題。
下面是顯示下載圖標快照的鏈接。 index.json file