站内搜索: 请输入搜索关键词

当前页面: 开发资料首页JSP 专题struts-config.xml中的 action配置set-property标签如何使用

struts-config.xml中的 action配置set-property标签如何使用

摘要: struts-config.xml中的 action配置set-property标签如何使用


我在CLASS中配置了相应的属性的GET/SET方法
但是还是抛出异常
Begin event threw exception
java.lang.NoSuchMethodException: Bean has no property named


你是怎么写struts-config.xml的?贴出来看


<?xml version="1.0" encoding="UTF-8"?>
struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">



<form-beans />














??
去看一下http://struts.apache.org/dtds/struts-config_1_2.dtd
你这种写法不符合吧?


给个例子先


你的这个标签要用到的呀
<form-beans >
<form-bean name="XX" type="你的form" />
<form-beans />


哪里有这么写的?
你把学的知识都记混了吧。
action里面不能定义set-property!!!



标签中允许有set-property子标签


???????????????


着急呀,没有人会吗?



楼主我支持你
-----------------
松自萧萧云自飘
风中独酌亦逍遥
抚却凡愁与尘念
琴韵未解恨已销


应该是动态actionform才用set-property属性。


actionForm 才有set-property属性
如果自己写Form类继承actionForm 在类中写get,set方法就不用在<form-beans >
<form-bean name="XX" type="你的form" />
<form-beans />里面加上 set-property属性,要是写了set-property属性就不用写自己的Form类了,两种写法都可以

其实set-property属性就是get set方法


好像不是正确的解法,我看到一个很简单的帖子说正确的做法是
在STRUTS-CONFIG.XML配置文件中的标签中增加TYPE属性,在这个属性是一个CLASS文件,这个CLASS负责在ACTION实例化的时候,负责装配这些属性。
但这个帖子说的很简单,我需要一个例子,希望大家赐教


看来大家都没有认真看书,只是一样葫芦


不好意思,刚才说错了。

http://blog.csdn.net/rabbit2003/archive/2005/06/30/408691.aspx


??????????


多谢


struct中action-mappings/action可以拥有set-property子标签,这里描述它的用法。

要使用action-mappings/action/set-property,需要编写ActionMapping子类,并给action-mappings 标签加上type属性,属性值就是我们编写的字类。这样当action的execute享有客户操作时将得到我们编写的ActionMapping事例。

我们编写的ActionMapping要具有action-mappings/action/set-property所设置的所有属性。如果action-mappings/action拥有set-property子标签,那么execute方法获得的ActionMapping事例就拥有set-property所设置的属性值。

例:

1.struts_config.xml







2.testActionMapping

public testActionMapping extends ActionMapping
{
....
private String name;
String getName(){return name;}
void setName(String val){name = val;}
...
}


3.testAction
public testAction extends Action
{
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm,
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
{
testActionMapping testForm = (testActionMapping )actionForm;
String name = testForm.getName();
}
}

我也看了,前面代码,我也不是很清楚,但这句testActionMapping testForm = (testActionMapping )actionForm;
拿ActionMapping来强转actionForm对象???这对么??


↑返回目录
前一篇: jboss 配置 oracle 数据源
后一篇: 做了一个Cometdemo,老板不相信它是comet