structs1开始

今天第一次接触上structs1版本为structs1.3


老师给的项目名字为test,引用了strcts1中的org.apache.struts.action.Action;

在WEB-INF 中有文件夹lib,把structs1的jar包导入到这个文件夹下。



项目导入后报错:String cannot be resolved to a type.


1.配置structs1时,编写structs-config文件。

<structs-config>
        <form-beans>
        <form-bean name="loginForm" type="com.kqh.structsTest.LoginActionForm"/>
        </form-beans>
        <global-excetions/>
        
        <global-forwards />
        <action-mapping>
              <action path="/login" type="com.kqh.structsTest.LoginActionForm" name="loginForm" scope="request">
              <foward name="success" path="/login_success.jsp"/>
              <forward name="error" path="/login_error.jsp" />
              </action>
        </action-mapping>
</structs-config>
然后出现了小红叉并且错误问题是The content of element type "action" must match "(icon?,display-
 name?,description?,set-property*,exception*,forward*)".
最后发现竟然是forward 拼错了,不能被structs识别造成的。<img alt="尴尬" src="http://static.blog.csdn.net/xheditor/xheditor_emot/default/awkward.gif" />
</pre><pre name="code" class="html">
 
2.LoginActionForm loginForm = (LoginActionForm)form;

改行报错Cannot cast from ActionForm to LoginActionForm。

原因是LoginActionForm类还没有写完,没有extends Actionform类。所以转换也是不能的。

3.Missing configuration resource for path /WEB-INF/struts-config.xml

原因是struts-config.xml的文件名写错了。

4.No action config found for the specified url

原因是struts-config中的标签拼错了。


5.source cannot be null

struts-config:

<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.bjsxt.strutstest.LoginActionForm" />
</form-beans>
<global-exceptions />


 <global-forwards />
<action-mappings>
<action path="/login" type="com.bjsxt.strutstest.LoginAction"
name="loginForm" scope="request">
<forward name="success" path="/login_success.jsp" />
<forward name="error" path="/login_error.jsp" />
</action>
</action-mappings>

</struts-config>

标红处是不一样的,上面的是bean的路径,而下面是servlet的路径。





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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值