jersey 过滤器
这里使用的Jersey 是 1.1 版本
1. web.xml 配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>restDemo</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> <servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.mtour.rest.resources.requestFilter</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping> </web-app>
2. 新建 类 requestFilter
package com.mtour.rest.resources; import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status; import com.sun.jersey.spi.container.ContainerRequest;
import com.sun.jersey.spi.container.ContainerRequestFilter; public class requestFilter implements ContainerRequestFilter{ @Override
public ContainerRequest filter(ContainerRequest arg0) {
// TODO Auto-generated method stub throw new WebApplicationException(
Response.status(Status.INTERNAL_SERVER_ERROR).build()); } }
当 请求过来的时候首先到达这里,这里做了测试 直接返回500 错误
抓包查看返回
jersey 过滤器的更多相关文章
- jersey 过滤器名称绑定的问题 NameBinding Provider
查资料也不容易查,这个问题困扰了我两天. 当没有 @Provider 的时候 过滤器不会被执行.
- 基于JerseyToken安全设计
网上Jersey中文资料不多,更别提其他了.本人跟进项目具体需求弄了简单的api认证机制 基本流程图 后端登录退出代码: @Path("Account") public class ...
- springboot配置文件priperties大全
flyway.baseline-description 执行基线时标记已有Schema的描述. flyway.baseline-on-migrate 在没有元数据表的情况下,针对非空Schema执行迁 ...
- Spring Boot属性文件配置文档(全部)
This sample file is meant as a guide only. Do not copy/paste the entire content into your applicatio ...
- [转]application.properties详解 --springBoot配置文件
本文转载:http://blog.csdn.net/lpfsuperman/article/details/78287265###; # spring boot application.propert ...
- application.properties详解 --springBoot配置文件【转载】
# spring boot application.properties配置的各个属性详解 # 该示例文件作为标准提供.(官方文档 翻译过来的) # 还是花了些功夫翻译,各位如果转发,请留下本文地址, ...
- springboot中配置文件application.properties的配置详情,数据源配置
pring Boot使用了一个全局的配置文件application.properties,放在src/main/resources目录下或者类路径的/config下.Sping Boot的全局配置文件 ...
- springboot 配置文件说明
你可以在自己创建的组件上使用@ConfigurationProperties注解,而Spring Boot自动配置的很多组件也添加了@ConfigurationProperties注解,可以通过Spr ...
- spring boot application.properties 配置参数详情
multipart multipart.enabled 开启上传支持(默认:true) multipart.file-size-threshold: 大于该值的文件会被写到磁盘上 multipart. ...
随机推荐
- Windows Phone 之文件下载进度和速度显示
用http协议来下载网络上的文件,通常我们需要获取文件的下载进度和下载的速度来给用户等待过程的一个交代,那么在windows phone 7下可以使用WebClient类来实现这一功能,HttpWeb ...
- kaptcha小案例(转)
使用kaptcha生成验证码 kaptcha是一个简单好用的验证码生成工具,通过配置,可以自己定义验证码大小.颜色.显示的字符等等.下面就来讲一下如何使用kaptcha生成验证码以及在服务器端取出验证 ...
- CANoe 入门 Step by step系列(二)CAPL编程【转】
CAPL就是Communication Application Programming Laguage的缩写,CAPL类似于C语言的语法,因此所有的语法请参考C语言教程,这里不在这里进行详述,关于C语 ...
- mac os x 10.9.1 安装 Homebrew软件包管理工具及brew安装maven3.1.1
Mac OSX上的软件包管理工具,安装软件或者卸载软件. 打开终端输入(如不行,可参考homebrew官网): ruby -e "$(curl -fsSL https://raw.githu ...
- linux c++ 遍历一个目录下的文件名 (包括子目录的文件名)
最近写代码有一个要遍历目录下的每一个文件并取得这个文件的绝对路径的需求, 我们知道linux c++中有system命令所以我在代码中 先生成了一个log,然后去读log文件的每一行文件名,然后给存储 ...
- 4537: [Hnoi2016]最小公倍数
Description 给定一张N个顶点M条边的无向图(顶点编号为1,2,…,n),每条边上带有权值.所有权值都可以分解成2^a*3^b的形式.现在有q个询问,每次询问给定四个参数u.v.a和b,请你 ...
- Android中自定义ListView无法响应OnItemClickListener中的onItemClick方法问题解决方案
如果你的自定义ListViewItem中有Button或者Checkable的子类控件的话,那么默认focus是交给了子控件,而ListView 的Item能被选中的基础是它能获取Focus,也就是说 ...
- Eclipse插件卸载
以前搞过安卓,重装系统后,安卓损坏了,每次还会提示那个窗口很烦人. 使用Eclipse自带的卸载插件功能即可,Help->About Eclipse->Inst ...
- log4j_slf4j log4j.properties
hibernate 使用的日志是slf4j,而 slf4j又有各种实现策略. 使用log4j 就是其中一种方式. 需要的jar 包: log4j-1.2.16.jar slf4j-api-1.6.1. ...
- lc面试准备:Implement Queue using Stacks
1 题目 Implement the following operations of a queue using stacks. push(x) -- Push element x to the ba ...