0
我正在學習過濾器。我使用netbens 8.02。無法從HTML頁面調用Java過濾器
我有一個silmple html頁面:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/css.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<nav>
<form action="f">
<label for="username">User: </label><input name ="username" type="text">
<label for="password">Password: </label><input name ="password" type="password">
<input type="submit" value="Vai">
</form>
</nav>
<section id ="page">
</section>
</body>
</html>
而且我試圖調用一個名爲「F」的過濾器,但每次我構建並運行broject,我嘗試嘗試登錄後裝入過濾器我得到的404消息:
type Status report
message /Filtri/f
description The requested resource is not available.
這是我的web.xml文件:(通過內置的NetBeans)
> <?xml version="1.0" encoding="UTF-8"?> <web-app version="3.1"
> xmlns="http://xmlns.jcp.org/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
> http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
> <filter>
> <filter-name>f</filter-name>
> <filter-class>f</filter-class>
> </filter>
> <filter-mapping>
> <filter-name>f</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> <session-config>
> <session-timeout>
> 30
> </session-timeout>
> </session-config> </web-app>
這是我的項目階段:Project hierachy
你能幫助我嗎?
您必須提及針對的完全限定類的過濾器 –
Kartic
另外還有一個通道:一個Servlet過濾器是一個可以攔截針對您的Web應用程序的HTTP請求的對象,您應該創建一個Servlet而不是Filter – Kartic