struts2遇到的问题
来源:互联网 发布:索尼和夏普电视 知乎 编辑:程序博客网 时间:2024/04/29 11:30
1、在建立拦截器的时候,对用户名进行验证,开始是是这样
ActionContext act = invocation.getInvocationContext();Map session =act.getSession();String user = (String) session.get("username");
但发现,user的返回值一直为空
然后,在Action中加入
ActionContext.getContext().getSession().put("username", username);
这样,每次user都能返回上一个用户的名字,与自己的期望并不一样,经过各种查找,才明白,下面这种方式才能获取jsp中的数据
ActionContext act = invocation.getInvocationContext();Map<String, Object> session = act.getParameters();String[] user = (String[]) session.get("username");System.out.println(user[0]);
2、需要在web.xml中将/*配置为*.action时需要一些地方需要注意
1>首先web.xml中的对比
*action的配置
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping>
/*的配置
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
2>jsp中的对比
*action中的写法
<form action="caoni.action">
/*中的写法
<form action="caoni">
3>如果web.xml中的配置为*.action时jsp中不能使用struts2的标签
必须在web中配置如下代码
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping>
0 0
- struts2遇到的问题
- Struts2遇到的问题
- 初学struts2遇到的问题
- 配置struts2遇到的问题
- 使用Struts2遇到的问题
- Struts2的配置,以及遇到的问题
- struts2学习中遇到的一些问题
- struts2 中使用 servlet遇到的问题
- 初学struts2编程遇到的问题
- 猜数字,struts2改写遇到的问题。
- struts2学习中遇到的问题
- Struts2集成Tiles2遇到的问题
- struts2.2配置遇到的问题
- 用struts2遇到的相关问题集
- 使用struts2 convention插件遇到的问题
- Struts2上传时遇到的问题
- struts2 配置 学习 以及遇到的问题
- struts2开发中经常遇到的问题
- JXPath(1.3)的简单示例
- iOS开发的一些奇巧淫技
- 九度OJ 1034 寻找大富翁
- 《PCI express体系架构导读》读书笔记一
- getResource()和getResourceAsStream以及路径问题
- struts2遇到的问题
- heartbeat及相关组件的安装
- php中的PDO使用详解
- 关于苹果APNS推送机制中各生成文件(CSR、证书、Provisioning文件)的关系的梳理,以及各种坑
- UML类图中会涉及到的一些概念、关系
- poj1603 floyd算法入门
- Effective.C 读书笔记03
- NFS mount失败及优化
- 按位 BEQ(相等跳转) bne(不相等跳转) 手札