学了一段时间struts2,跟着教程做,但发现struts2的版本不同,很多东西的使用是有差异的。例如之前遇到的创建sessionFactory的方式就跟之前版本有着明显的差异。今天又遇到一个问题,那就是通配符的使用。

问题:若不使用通配符,可以找到相对应的action,而使用通配符就会报错,找不到actionmapping之内的错,找不到action。

问题原因: struts2.5 为了增加安全性,在 struts.xml 添加了这么个属性:<global-allowed-methods>regex:.*</global-allowed-methods>

解决:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <package name="default" namespace="/" extends="struts-default">
<global-allowed-methods>regex:.*</global-allowed-methods>
<action name="helloworld" class="com.imooc.action.HelloWorldAction">
<result>/result.jsp</result>
<result name="add">/add.jsp</result>
<result name="update">/update.jsp</result>
</action> </package> <constant name="struts.enable.DynamicMethodInvocation" value="true"></constant> </struts>
1.首先,注意头部信息,这个应该是用来指定文件中允许使用那些标签。
  <!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd">
2.加上下面这句。
  <global-allowed-methods>regex:.*</global-allowed-methods>
 或者(不加上面这句),在action中加上指定允许调用的方法的语句:
  <allowed-methods>login,logout</allowed-methods>
  
  

最新文章

  1. 初试WIX加SQL LocalDB
  2. C--变量的命名规则
  3. HTTP与AJAX深入揭秘,不使用AJAX实现页面无刷新
  4. springMVC乱码问题-转
  5. 【转载】ODBC, OLEDB, ADO, ADO.Net的演化简史
  6. jQuery实现登录提示
  7. openstack 实例迁移
  8. HDU(搜索专题) 1000 N皇后问题(深度优先搜索DFS)解题报告
  9. auto space advisor
  10. 找不到方法: Int32 System.Environment.get_CurrentManagedThreadId() .
  11. Ajax笔记 XHR XMLHttpRequest
  12. strlen出错
  13. flask第一章 flask启动 路由视图 FlaskRequest jinja2 FlaskSession
  14. Eclipse Tomcat部署web项目时出现There are no resources that can be added or removed from the server解决办法
  15. NOIP2017题解
  16. 关于Error during managed flush [Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1]错误
  17. .Net MVC发布出错 Server Error in &#39;/&#39; Application.
  18. python pbr 打包
  19. Linux命令——磁盘管理
  20. Restful api 防止重复提交

热门文章

  1. -- &gt; define的用法与学习(1)
  2. js有块级作用域么?
  3. centos6.2安装kvm虚拟机
  4. Android CardView使用和导入出错问题
  5. 寒城攻略:Listo 教你用 Swift 写IOS UI 项目生活记事本
  6. YTU 2795: 编程题AB-侦察员的密码
  7. 大文件Copy 大数据量复制
  8. [python基础] csv.wirterow()报错UnicodeEncodeError
  9. JSP-Runoob:JSP 点击量统计
  10. Spark SQL读parquet文件及保存