JBOSS 上的 URL 不支持 HTTP 方法 POST

HTTP method POST is not supported by this URL on JBOSS

我们必须为我们在 Struts-1 上的遗留应用程序之一设置 MS azure 活动目录身份验证,将 运行 在 JBOSS EAP-7 上。

基本设置是这样的。我们有一个名为 index.html 的欢迎文件,如下所示。

<html>
 <head>
  <title>TITLE</title>
 </head>
 <FRAMESET border=0 name=fs_rep ROWS="18%,*">
  <FRAME SRC="heading.html" NAME="HEADING">
  <FRAME SRC="logon.jsp" NAME="DISPLAY">
 </FRAMESET>
 <NOFRAMES>
  This browser does not support frames. The application cannot be displayed.
</NOFRAMES>
</html>

当应用程序启动时,用户看到登录页面,提供凭据,请求转到 LoginAction class,后者执行 LDAP 验证。

我们正在关注这个 link https://docs.microsoft.com/en-us/azure/active-directory/active-directory-devquickstarts-webapp-java 用于设置 MS AD 身份验证。

我们在 web.xml 中创建了一个基本过滤器

<filter-name>BasicFilter</filter-name>
<url-pattern>/index.html</url-pattern>

此筛选器包含身份验证代码并将用户重定向到 Azure 登录页面。我们将天蓝色的 "Response URL" 设为:http://localhost:8001/MyApp/index.html

此设置适用于 Weblogic 服务器,但当我尝试在 JBOSS EAP-7 上部署相同内容时,它会将我们带到 MS Azure 注册页面,我们提供凭据,基本过滤器 运行s,最后它在浏览器中显示“HTTP 方法 POST 不受此 URL 支持”。

我们走错路了吗? POST 如何支持 URL(仅在 JBOSS 中出现)

似乎 .html 文件的 HTTP 方法 POST 在 JBoss 上默认不受支持,这与其他 servlet 引擎不同。

根据我的经验,我认为有一些方法可以解决这个问题。

  1. 这似乎是对 JBoss 的安全约束,可以通过尝试在项目的 web.xml 文件中设置以下配置来更改。

    <security-constraint>    
      <display-name>Example Security Constraint</display-name>    
      <web-resource-collection>    
         <web-resource-name>Protected Area</web-resource-name>    
         <url-pattern>/index.html</url-pattern>   
         <http-method>GET</http-method>    
         <http-method>POST</http-method>  
      </web-resource-collection>
    </security-constraint> 
    
  2. 作为解决方法,您可以尝试将 index.html 重命名为 index.jsp。这会将您的 HTML 编译为 JBoss serlvet 容器上的 JSP 运行,并且 JSP 始终使用 service() 方法,这应该避免JBoss.

  3. 上的问题