struts2-拦截器 过滤文字
来源:互联网 发布:小度掌柜商家版mac 编辑:程序博客网 时间:2024/06/05 16:16
1.编写代码 实现在jsp页面 写内容 使用拦截器 过滤一些文字
1.先编写jsp显示页面的代码
2.配置struts.xml
<!-- (1)中文乱码处理 表单递交和参数传递适用 数据的乱码不能处理 -->
<constant name="struts.i18n.encoding" value="gb2312"/>
配置拦截器类
<interceptors>
<interceptor name="inter1" class="com.interception.action.MyInterceptor"></interceptor>
</interceptors>
还必须用到defaultStack这个包的方法
<interceptor-ref name="defaultStack"></interceptor-ref>
在这里使用
<interceptor-ref name="inter1"></interceptor-ref>
3.action 端com.interception.action.MyInterceptor 验证类的方法
先继承一个类 并实现方法
//获取当前的action(InterAction)
System.out.println("拦截器在执行");
获取需要验证的action
InterAction action=(InterAction)interceptor.getAction();
if(action!=null) //InterAction 的业务方法正在执行
{
String oldcontent=action.getContent();
System.out.println(oldcontent+"++++++++");
判断是否有这个字符串
if(oldcontent.contains("常信院"))
{
调用replaceFirst替换字符串部分内容
String newcontent=oldcontent.replaceFirst("常信院", "替换的内容");
System.out.println(newcontent+"========");
action.setContent(newcontent);(设置action的新内容)
}
return interceptor.invoke(); (成功需调用这个方法)
}
else {
return Action.LOGIN; (不成功则返回字符串 login)
}
- struts2-拦截器 过滤文字
- struts2 文字过滤拦截器
- struts2拦截器-文字过滤拦截器实例
- 文字过滤拦截器
- jsp struts2 学习(五) ----- 文字过滤拦截器
- ssh框架学习-struts2 使用自定义拦截器进行文字过滤拦截
- struts拦截器文字过滤拦截器
- struts2拦截器实现session会话过滤
- Struts2拦截器的方法过滤
- Struts2拦截器的方法过滤
- 【Struts2】:拦截器实现方法过滤
- Struts2拦截器之拦截器的方法过滤
- Struts2拦截器之拦截器的方法过滤
- Struts2拦截器之拦截器的方法过滤
- struts2拦截器值拦截器的方法过滤
- struts2--实现文字过滤功能
- struts2文件过滤拦截器fileUpload以及各种文件类型
- struts2文件过滤拦截器fileUpload以及各种文件类型
- Eclipse下Web开发环境的搭建
- linux下安装oracle9204Error in invoking target install of makefile /apps/oracle/OraHome1/plsql/lib/ins_p
- 探梦方寸间 移动终端CPU、GPU浅析(转)
- 如何查看僵死进程
- 详解C++ friend关键字
- struts2-拦截器 过滤文字
- check约束能加if条件的吗???
- Indexed Nearest Neighbour Search in PostGIS
- Linux /etc目录详解
- SharePoint 2007 Web Content Management 性能优化系列 3 – IIS压缩
- 转:决策树模型组合之随机森林与GBDT
- SharePoint 2007 Web Content Management 性能优化系列 2 – 32 bits or 64 bits ?
- 企业CEO与ERP软件公司
- SharePoint 2007 Web Content Management 性能优化系列 1 – 做好拓扑架构规划