无法从 HTML 页面调用 Java 过滤器
Cannot call Java Filter from an HTML page
我正在努力学习过滤器。我用的是netbens 8.02.
我有一个简单的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" 的过滤器,但每次我构建和 运行 项目并在尝试登录后尝试加载过滤器时,我都会收到 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
你能帮帮我吗?
Filter
拦截或者预处理了一个请求,但是请求还是需要去到一个资源(一个servlet
,一个jsp
,或者html
页)否则,服务器将响应 404
您正在 f
请求资源,但尽管过滤器可能会拦截请求,一旦过滤器完成处理,服务器仍会尝试将您发送到 f
,这是在你的上下文中的任何内容。
我正在努力学习过滤器。我用的是netbens 8.02.
我有一个简单的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" 的过滤器,但每次我构建和 运行 项目并在尝试登录后尝试加载过滤器时,我都会收到 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
你能帮帮我吗?
Filter
拦截或者预处理了一个请求,但是请求还是需要去到一个资源(一个servlet
,一个jsp
,或者html
页)否则,服务器将响应 404
您正在 f
请求资源,但尽管过滤器可能会拦截请求,一旦过滤器完成处理,服务器仍会尝试将您发送到 f
,这是在你的上下文中的任何内容。