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> & ...
随机推荐
- C# 小笔记
1,Using using (var ws = new WebSocket ("ws://dragonsnest.far/Laputa")) { ws.OnMessage += ( ...
- 分布式文件系统FastDFS动态扩容
当用户量越来越大,则集群中某个group总会到达其极限,这时就得扩展集群的容量了. FastDFS的扩容分为对group纵向扩容和横向扩容 纵向扩容 指在同一个group组中增加服务器,实现数据冗余, ...
- 常用sql语句整理:mysql
## 常用sql语句整理:mysql1. 增- 增加一张表```CREATE TABLE `table_name`( ... )ENGINE=InnoDB DEFAULT CHARSET=utf8 ...
- 正则API
正则表达式:规定字符串中字符出现规律的公式 如果备选字符列表中个别字符之间是连续的,可用-省略中间的字符.比如: 匹配1位数字: [0-9]匹配1位小写字母 : [a-z] 匹配1位大写字母 : ...
- bootstrap-multiselect 的简单使用,样式修改,动态创建option
1.bootstrap-multiselect 顾名思义基于bootstrap,bootstrap基于jquery,所以第一步,引入文件 bootstrap.css/ juery.js /bootst ...
- 洛谷 P1099 树网的核
P1099 树网的核 题目描述 设T=(V, E, W) 是一个无圈且连通的无向图(也称为无根树),每条边到有正整数的权,我们称T为树网(treebetwork),其中V,E分别表示结点与边的集合,W ...
- svn checkout The XML response contains invalid XML
svn checkout 报错:The XML response contains invalid XML 待解决? ---目前没有找到好的解决方法,svn数据库中存的log入手应该可以,有时间再去看 ...
- 使用BIOS进行键盘输入和磁盘读写
body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...
- 序列化和Json
实现了python与python程序之间内存的交互 常用场景: 1 把内存的数据写到磁盘 2 socket只能传字符串,二进制,通过序列化 ============================== ...
- 捕获arm托管磁盘虚拟机,并进行还原
背景:托管磁盘虚拟机"hlmma69n2",附加了一块100GB的数据磁盘.可以通过Portal管理界面直接捕获该虚拟机并进行还原,详情见如下步骤: 1.在虚拟机内部执行一般化的操 ...