Struts2 中添加 Servlet
Struts2中如何添加Servlet
以前Java开发都是Servlet的天下,如今是各种框架横行,遇到一个需要将以前的Servlet加入到现有的Struts2的环境中。
Google之后发现Stack Overflow真是个好东西,解决如下,只是简单配置下。
I assume you want to know how to use a servlet in conjunction with Struts2 when you have mapped everything to the Struts2 filter.
You can use the following in your struts.xml:
<constant name="struts.action.excludePattern" value="/YourServlet"/>
You can exclude multiple patterns by separating them with a comma, such as:
<constant name="struts.action.excludePattern" value="/YourServlet,/YourOtherServlet"/>
参考
Filter mapping for everthing to Struts2 besides one servlet?
Filters not working in Struts2
- 其实Struts2 的文档中有记载Static Content
Preventing Struts from Handling a Request
If there is a request that Struts is handling as an action, and you wish to make Struts ignore it, you can do so by specifying a comma separated list of regular expressions like:
<constant name="struts.action.excludePattern" value="/some/conent/.*?" />
These regular expression will be evaluated against the request's URI (HttpServletRequest.getRequestURI()), and if any of them matches, then Struts will not handle the request.
To evaluate each pattern Pattern class from JDK will be used, you can find more about what kind of pattern you can use in the Pattern class JavaDoc.
除了上面在Struts2 里面自带的方法
1. 在web.xml中配置需要请求的Servlet
<servlet-mapping>
<servlet-name>Authcode</servlet-name>
<url-pattern>/authcode.servlet</url-pattern>
</servlet-mapping>
2. 在过滤器中Request的请求进行Servlet判断并进行处理
Struts2 中添加 Servlet的更多相关文章
- Struts2中使用Servlet API步骤
Struts2中使用Servlet API步骤 Action类中声明request等对象 Map<String, Object> request; 获得ActionContext实例 Ac ...
- struts2中访问servlet API
Struts2中的Action没有与任何Servlet API耦合,,但对于WEB应用的控制器而言,不访问Servlet API几乎是不可能的,例如需要跟踪HTTP Session状态等.Struts ...
- IDEA中添加servlet的jar
问题解决:办法1:使用Project Structure 方法二:使用Maven 在pom.xml文件中添加如下
- Struts2中获取servlet API的几种方式
struts2是一个全新的MVC框架,如今被广大的企业和开发者所使用,它的功能非常强大.这给我们在使用servlet 纯java代码写项目的时候带来了福音.但是一般来说,我们的项目不到一定规模并不需要 ...
- maven中添加servlet、jsp依赖
或者在eclipse中,右键项目名称->Maven->Add Dependency->输入servlet,会自动找到最新的版本(记得联网哦),如图:
- 在web.xml中添加servlet报错问题
出现这种问题的原因是因为servlet-name标签中没有名称,如果错误出现在servlet上,也是一样,补充servlet-name名称即可.如下图
- struts2中Action訪问servlet的两种方式
一.IoC方式 在struts2框架中,能够通过IoC方式将servlet对象注入到Action中.通常须要Action实现下面接口: a. ServletRequest ...
- Struts2(八)访问Servlet API
一.Struts2中的Servlet API 1.1.struts2的Action实现了MVC中C层的作用 针对请求用户显示不同的信息 登录后段保存用户信息 ----session 保存当前在线人数等 ...
- web项目中添加定时任务
1.在web.xml中添加servlet <servlet> <servlet-name>StatisticInitServlet</servlet-name> & ...
随机推荐
- 98、vue.js简单入门
本篇导航: 介绍与安装 vue常用指令 一.介绍与安装 vue是一套构建用户界面的JAVASCRIPT框架.与其它大型框架不同的是,Vue 被设计为可以自底向上逐层应用.Vue 的核心库只关注视图层, ...
- Linux 将本地文件上传Linux服务器, 即ssh 命令上传本地文件
利用ssh传输文件 在linux下一般用scp这个命令来通过ssh传输文件. 1.从服务器上下载文件 scp username@servername:/path/filename /var/www ...
- tp5 $_ENV获取不到数据
$_ENV变量是取决于服务器的环境变量的,从不同的服务器上获取的$_ENV变量打印出的结果可能是不同的. php的配置文件php.ini的配置项为:variables_order = "GP ...
- XHR
xhr注入 XHR 注入技术是通过XMLHttpRequest来获取javascript的.但与eval不同的是,该机制是通过创建一个script的DOM元素,然后把XMLHttpRequest的响应 ...
- mysql 两个时间段的差,可以是秒,天,星期,月份,年...
SELECT TIMESTAMPDIFF(SECOND, now(), "2012-11-11 00:00:00") 语法为:TIMESTAMPDIFF(unit,datetime ...
- MapReduce 原理与 Python 实践
MapReduce 原理与 Python 实践 1. MapReduce 原理 以下是个人在MongoDB和Redis实际应用中总结的Map-Reduce的理解 Hadoop 的 MapReduce ...
- 前端HTML介绍
一.HTML简介 HTML定义: 超级文本标记语言是标准通用标记语言下的一个应用,也是一种规范,一种标准,它通过标记符号来标记要显示的网页中的各个部分.网页文件本身是一种文本文件,通过在文本文件中添加 ...
- hdevelop (halcon)处理大分辨率图像问题
HALCON 的ide有2种模式:hdevelop 和hdevelop xl hdevelop 适用于普通分辨率的图像,小于等于 32k x 32k : hdevelop xl适用于大分辨率的图像,大 ...
- jQuery hover() 方法
$("p").hover(function(){ $("p").css("background-color","yellow&qu ...
- Python---socketserver
为方便以后学习和查询,特从socketserver架构.源码分析和案例三方面进行总结 1. Python之socketserver架构 2. Python之socketserver源码分析(一) 3. ...