我有一个使用基于表单的身份验证在 JBOSS 中运行良好的 Web 项目。但是当我在 websphere 7 中部署相同的内容时,我收到了 HTTP 500 错误。
我的web.xml
<display-name>Test</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.apache.tiles.web.startup.TilesListener</listener-class>
</listener>
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<security-constraint>
<web-resource-collection>
<web-resource-name>test_actions</web-resource-name>
<description></description>
<url-pattern>*.action</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description></description>
<role-name>testuser</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<description></description>
<role-name>testuser</role-name>
</security-role>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Default</realm-name>
<form-login-config>
<form-login-page>/login_form.jsp</form-login-page>
<form-error-page>/login_error.jsp</form-error-page>
</form-login-config>
</login-config>
索引.html
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TEST</title>
</head>
<body onload="document.MainForm.submit();">
<form action="welcomeAction.action" method="post" id="MainForm" name="MainForm">
</form>
</body>
</html>
我有一个拦截器AuthorizationInterceptor,它扩展了 RolesInterceptor,这个拦截器实际上检查用户是否存在于我们的 DB请求中。getUserPrincipal ().getName()用于获取用户 ID。所以当welcomeAction.action被调用时,它应该来到 AuthorizationInterceptor,但从不请求到达这里。
在 websphere 中,我启用了全局安全性。Websphere LoginForm 示例工作正常。我应该自己纠正一个j_security_check过滤器吗?或 websphere webcontainer 处理这个。(在 LoginForm 中我看到了 LoginFilter 代码)。但我相信 websphere webcontainer 应该处理 j_security_check 的东西,比如 jboss 或 tomcat ..