0

我是 java web 编程的新手,我的老板给我分配了一项艰巨的任务(对我来说)。我们在 tomcat 服务器中托管了一个 html 表单,它被提交到不同服务器中的 php 页面。现在我的老板想要添加表单中的验证码,但不想在 php 页面中进行身份验证。所以我想我可能会实现一个过滤器并在那里进行身份验证。

<form action="http://differentproject.com/display.php" method="Post">
            <input type="text" name="text"></input>
            <input type="Submit" value="submit"/>
        </form>

所以让我们考虑上面是我的 html 页面和表单提交给 display.php。我想用过滤器拦截它,但下面的 url 模式不起作用。

<filter-mapping>
        <filter-name>test</filter-name>
        <url-pattern>http://differentproject.com/display.php</url-pattern>
    </filter-mapping>

这也不是,

<filter-mapping>
            <filter-name>test</filter-name>
            <url-pattern>/display.php</url-pattern>
        </filter-mapping>

我认为它不起作用,因为 url 超出了项目范围。可以使它起作用吗?

4

1 回答 1

1
it is submitted to a php page in different server

You can only filter or intercept this on the different server (the php server, not the tomcat server) because as soon as the user submits the form, the browser makes a request to the different server. Your tomcat server is not involved anymore.

You would either need to

  • change the original form to no longer submit to the different server
  • get the php server to redirect the request to where you want it to go
于 2013-04-11T07:29:47.900 回答