需求其实就是把eclipse osgi导出的应用嵌入到原有的ssh开发的程序中。
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>*.htm</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/struts/*</url-pattern>
</filter-mapping>
把eclipse osgi应用嵌入需要在web.xml中添加:
<servlet id="bridge">
<servlet-name>equinoxbridgeservlet</servlet-name>
<servlet-class>org.eclipse.equinox.servletbridge.BridgeServlet</servlet-class>
<init-param>
<param-name>commandline</param-name>
<param-value>-console</param-value>
</init-param>
<init-param>
<param-name>enableFrameworkControls</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>extendedFrameworkExports</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>equinoxbridgeservlet</servlet-name>
<url-pattern>
/osgi/*
</url-pattern>
</servlet-mapping>
由于struts的filter过滤了htm,导致osgi的htm文件被struts"劫"取了~~
经过一番挣扎,解决方法如下:
在struts过滤器中增加排除参数。
<filter>
<filter-name>struts</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
<init-param>
<param-name>struts.action.excludePattern</param-name>
<param-value>/osgi/.*</param-value>
</init-param>
</filter>
为啥怎么弄,解释如下:
1、 读取init-param初始化参数
protected List<Pattern> excludedPatterns = null;
public void init(FilterConfig filterConfig) throws ServletException {
InitOperations init = new InitOperations();
try {
FilterHostConfig config = new FilterHostConfig(filterConfig);
init.initLogging(config);
Dispatcher dispatcher = init.initDispatcher(config);
init.initStaticContentLoader(config, dispatcher);
prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher);
execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher);
this.excludedPatterns = init.buildExcludedPatternsList(dispatcher);
postInit(dispatcher, filterConfig);
} finally {
init.cleanup();
}
}
public List<Pattern> buildExcludedPatternsList( Dispatcher dispatcher ) {
return buildExcludedPatternsList(
dispatcher.getContainer().getInstance(
String.class,
StrutsConstants.STRUTS_ACTION_EXCLUDE_PATTERN));
}
2、 使用
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
//父类向子类转:强转为http请求、响应
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
try {
//。。。@@
if ( excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) {
chain.doFilter(request, response);
} else {
request = prepare.wrapRequest(request);
ActionMapping mapping = prepare.findActionMapping(request, response, true);
if (mapping == null) {
boolean handled = execute.executeStaticResourceRequest(request, response);
if (!handled) {
chain.doFilter(request, response);
}
} else {
execute.executeAction(request, response, mapping);
}
}
} finally {
prepare.cleanupRequest(request);
}
}
参考资源:
http://ari.iteye.com/blog/829843
http://www.docjar.org/html/api/org/apache/struts2/dispatcher/ng/filter/StrutsPrepareAndExecuteFilter.java.html
servlet-mapping
http://selectshy.iteye.com/blog/1293458
Struts2的工作原理
http://space.itpub.net/13750068/viewspace-493899
Can I exclude some concrete urls from <url-pattern> inside <filter-mapping>?
http://stackoverflow.com/questions/3125296/can-i-exclude-some-concrete-urls-from-url-pattern-inside-filter-mapping
Filter mapping url-pattern that excludes subdirectories
http://stackoverflow.com/questions/3466897/filter-mapping-url-pattern-that-excludes-subdirectories
// First cast ServletRequest to HttpServletRequest.
HttpServletRequest hsr = (HttpServletRequest) request;
// Check if requested resource is not in /test folder.
if (!hsr.getServletPath().startsWith("/test/")) {
// Not in /test folder. Do your thing here.
}
http://www.blogjava.net/liuspring/archive/2008/09/01/226073.html
http://www.blogjava.net/liuspring/archive/2008/09/01/226073.html 写道
web.xml中<url-pattern>的3种写法
① 完全匹配
<url-pattern>/test/list.do</url-pattern>
② 目录匹配
<url-pattern>/test/*</url-pattern>
③ 扩展名匹配
<url-pattern>*.do</url-pattern>
servlet-mapping的重要规则:
☆ 容器会首先查找完全匹配,如果找不到,再查找目录匹配,如果也找不到,就查找扩展名匹配。
☆ 如果一个请求匹配多个“目录匹配”,容器会选择最长的匹配。
urlrewrite
http://tuckey.org/urlrewrite/
http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/4.0/index.html#filterparams
分享到:
相关推荐
rsync-homedir-排除该项目维护您可能不需要备份的目录和文件的列表,您可以将其传递给rsync命令的--exclude-from选项。用法: # download to `rsync-homedir-local.txt`wget ...
无服务器插件常见排除注意:此插件不再排除与AWS最佳实践...安装安装插件:npm install serverless-plugin-common-excludes --save-dev 将插件包含在serverless.yml : plugins : - serverless-plugin-common-excludes
<url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-...
总的来说,"cas-client扩展拦截器支持excludes"是一项针对CAS客户端的改进,它增强了系统的灵活性,允许开发者根据需求定制拦截策略,使得某些URL可以绕过认证流程,提高用户体验,同时也方便了系统的维护和管理。
<url-pattern>/*</url-pattern> </filter-mapping> (2)标签库配置: <taglib-uri>sitemesh-decorator</taglib-uri> <taglib-location> /WEB-INF/tld/sitemesh-decorator.tld </taglib-location> <taglib-...
如果使用此插件,则应禁用内置的Serverless选项以排除开发依赖关系,这反而较慢: package : excludeDevDependencies : false 还可以考虑使用serverless-plugin-common-excludes来进一步减小程序包大小,并考虑使用...
sitemesh 使用例子。 <?xml version="1.0" encoding="utf-8"?> <decorators defaultdir="/decorators"> <!-- 此处用来定义不需要过滤的页面 --> ... <pattern>/*</pattern> </decorator> </decorators>
<url-pattern>/*</url-pattern> </filter-mapping> ``` 3. **创建装饰模板** 创建一个基础 HTML 模板,例如 `layout.html`,包含页面的基本结构,如页头、页脚和主体区域。主体区域通常用 `<s:body>` 或 `...
Git 支持如果源文件在 git repo 下,请使用--git选项node-mv sample.js sample-renamed.js --git排除目录/文件您可以将正则表达式列表传递给--excludes以排除您不希望程序搜索的文件夹或文件node-mv sample.js ...
Apache OpenJPA-自述文件 前言 感谢您下载此版本的Apache OpenJPA。 Apache OpenJPA是Java Persistence API规范的实现。...$> mvn clean install -Dsurefire.excludes.locking=**/* 针对不同的数据库进
出口打字稿职能新创建index.ts文件时自动导出打字稿文件。 在index.ts文件中时,... " export-typescript.excludes " :[ " *.{spec.ts,spec.tsx} " ], " export-typescript.includes " :[ " *.{ts,tsx} " , " */index.{
--> <testResources> <testResource> ${project.build.testSourceDirectory}/resources</directory> <includes> **/*</include> </includes> <excludes> </excludes> </testResource> </testResources> </build> <!...
安装npm install --save-dev excludify例子包.json: { "excludify" : { "excludes" : [ "*.css" , "*.less" ] }} 壳: browserify index.js -t [ excludify --excludes " *.css " ] > bundle.js 浏览器 API: var b...
[-e excludes] [-c changelogs] OPTIONS --help, -h Prints the help. --version, -v Prints the package version. --format, -f Output format. One of either markdown, json, mackerel or csv
默认为当前目录-e/--excludes -(可选)以逗号分隔的软件包正则表达式列表以排除-o/--output -output-(可选)存储cobertura xml文件的路径。 默认为./coverage.xml -d/--demangle -demangle-(可选)对C ++函数...
然后,我们使用 `<excludes>` 元素来排除各环境的配置文件,防止在生成目录中多余其它目录。最后,我们使用 `${profiles.active}` 属性来指定当前激活的 Profile 的配置文件目录。 例如,如果当前激活的是 `pro` ...
- **excludes**:需要排除的文件模式。 - **示例**: ```xml **/*.class" excludes="**/test/**"/> ``` #### 七、`<javac>` 标签 - **描述**:用于编译Java源文件。 - **重要属性**: - **srcdir**:源代码...
- **decorator-mappers**:定义装饰器映射器,用于匹配URL和装饰器之间的关系。 #### 三、装饰器定义 装饰器是SiteMesh的核心概念之一,它定义了页面的布局结构。装饰器通常包含一个头部、一个底部以及一个或多个...
例如,通过设置maven-surefire-plugin的excludes和includes属性,我们可以控制哪些测试类应该被运行。此外,还可以使用profiles来为不同的环境定义不同的测试策略。在提供的压缩包文件名“mavenprofile”中,我们...
tar -cvzf backup.tar.gz --exclude-from=excludes.txt /path/to/directory ``` 其中`excludes.txt`包含要排除的文件或目录的列表。 14. **-T 或 --files-from** - **功能**:从指定文件中读取要添加到归档文件...