2013-04-11 82 views
0

我是一个java网络编程的新手,我的老板已经指派了我一个困难的任务(对我来说)。我们有一个在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.I想用一个过滤器拦截,但下面的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是淘汰项目的scope.Can它才能起作用?

回答

1
it is submitted to a php page in different server 

只能过滤或拦截此不同的服务器(PHP的服务器,而不是Tomcat服务器)上,因为只要用户提交表单时,浏览器向不同的服务器的请求。你的tomcat服务器不再涉及。

你要么需要

  • 更改的原始形式不再提交给不同的服务器
  • 让PHP服务器将请求重定向到你想要的地方去