玩Struts2.5.2时,遇到的小boss

一、核心包的引用(刚开始学时用到的jar)
删去xwork-core-2.x.x.jar 同时需要加入log4j-api-2.5.jar
这里写图片描述
二、web.xml中的filter的改变
若不按照下面的话会出现java.lang.ClassNotFoundException异常。

<filter-class>
    org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>

三、struts.xml文件的开头变了

<?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">

若不是,在使用一些特殊的标签时会出现类似于下面的异常。

1、必须声明元素类型 "global-allowed-methods"2、DOCTYPE struts这里有异常等

尤其是在使用通配符时出现这一类错误

还有就是Struts2.5在通配符上发生了一些变化

<package name="manage" namespace="/" extends="struts-default" >

  <global-allowed-methods>*</global-allowed-methods>  

    <action name="*_*" class="com.java1234.action.{1}Action" method="{2}">
        <result name="success">helloWorld.jsp</result> 
        <!-- 或者不用 <global-allowed-methods>*</global-allowed-methods>
            使用下面得allowed-method标签来指明方法
        -->
        <!-- <allowed-methods>add</allowed-methods> -->
    </action>
  </package>

就这些了,亲自体验过半天。。。。。。。

四、

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console..

若控制台出现这个错误,就是你的struts.xml文件出错了,一定要细心检查,不用添加log4j-core-2.5.jar等jar,将核心包加入即可,当然只是入门时所用的包。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值