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. ...
随机推荐
- Jquery 实现瀑布流功能
实现展示地址:http://sandbox.runjs.cn/show/mbojrgag 源码地址:http://runjs.cn/code/qps1jebl 效果截图:
- mysql5.7.14安装与配置
参考文章链接: http://jingyan.baidu.com/article/afd8f4de9006d934e286e9fd.html http://www.cnblogs.com/wenthi ...
- android code 和js的交互
小弟现在需要android code 和js的交互.出现了问题,求大家带一带啊. 我的页面:<!DOCTYPE html><html lang="en">& ...
- postgresql 的触发器
今天编写了一个触发器 功能: 有两个表,当一个表的字段有所改动的时候,另一个表跟着改动 CREATE OR REPLACE FUNCTION process_emp_audit() RETURNS T ...
- c++清除输入缓冲区之 sync() vs ignore()
最近在写程序的时候总是不注意输入缓冲区内是否还有东西,导致出现了一些异常,调试了半天.所以来上一贴,学习注意,引以为戒! http://blog.chinaunix.net/uid-21254310- ...
- 如何用OS X的Xcode写C语言程序
声明:以下内容非本人原创,转载于别处.拿出来只是分享给FY们,不喜勿喷!原创地址http://blog.yorkxin.org/posts/2009/03/15/fundamental-c-with- ...
- tomcat出现的PermGen Space问题(bat,或者eclipse启动。)
参考地址 http://www.blogjava.net/allen-zhe/archive/2007/12/18/168556.html 参考地址:http://javavsxiaoming.ite ...
- Rails中的测试RSpec升级遇到的问题
bundle exec rspec spec/ /home/wuxj/Prac/rrprac/sample_app/spec/spec_helper.rb::in `block in <top ...
- 从1500万用户巅峰跌落的app,血泪回顾图片社交那些坑
饭桌君说 第八届小饭桌创业课堂来了一位特殊的分享嘉宾,他曾经参与了一款当时极具风头的图片社交app的创始团队,靠谱团队,用户量急速上升到1500万,公司获得A轮……一切看上去都那么美好. 可是,由于各 ...
- Angular1.0
公司会议室组织分享,两个小时困死我了,一点凌乱笔记: $http.get和promise一样有then方法,成功,失败 jquery each遍历对象i,n ng-app ng-controller ...