浏览 5394 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2006-01-17
我可以把剛選擇的項目印出來,使用 <c:out value='${myForm.abcType}' /> 但不能設置radio 的default 值為之前選擇的項目. 請教為甚麼? <html:radio property="abcType" value="1" />a <html:radio property="abcType" value="2" />b <html:radio property="abcType" value="3" />c <c:out value='${myForm.abcType}' /> public final class myForm { private int abcType ; public int getAbcType() { return abcType; } public void setAbcType(int abcType) { this.abcType = abcType; } 如果我加入 name="abcType" <html:radio property="abcType" name="abcType" value="1" /> 就出現: Cannot find bean under name abcType 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2006-01-17
看你的标签应该用的struts吧,你应当在你的action里面拿到你的formbean的引用,然后将abcType赋值成你想要的值就可以了,
例如你设置了abcType=“1” <html:radio property="abcType" value="1" />a struts会自动帮你选中这个a的 |
|
返回顶楼 | |
发表时间:2006-01-17
lingcm 写道 看你的标签应该用的struts吧,你应当在你的action里面拿到你的formbean的引用,然后将abcType赋值成你想要的值就可以了,
例如你设置了abcType=“1” <html:radio property="abcType" value="1" />a struts会自动帮你选中这个a的 你看看我的code, 我應該已經設置了, 但都沒有反應. |
|
返回顶楼 | |
发表时间:2006-01-17
johnung 写道 當選擇了abcType其中一個後submit, 回到同一個page,
我可以把剛選擇的項目印出來,使用 <c:out value='${myForm.abcType}' /> 但不能設置radio 的default 值為之前選擇的項目. 請教為甚麼? <html:radio property="abcType" value="1" />a <html:radio property="abcType" value="2" />b <html:radio property="abcType" value="3" />c <c:out value='${myForm.abcType}' /> public final class myForm { private int abcType ; public int getAbcType() { return abcType; } public void setAbcType(int abcType) { this.abcType = abcType; } 如果我加入 name="abcType" <html:radio property="abcType" name="abcType" value="1" /> 就出現: Cannot find bean under name abcType 你需要在你的formbean中初始化一个值给这个属性 如 private int abcType=1; |
|
返回顶楼 | |
发表时间:2006-01-17
pure 写道 johnung 写道 當選擇了abcType其中一個後submit, 回到同一個page,
我可以把剛選擇的項目印出來,使用 <c:out value='${myForm.abcType}' /> 但不能設置radio 的default 值為之前選擇的項目. 請教為甚麼? <html:radio property="abcType" value="1" />a <html:radio property="abcType" value="2" />b <html:radio property="abcType" value="3" />c <c:out value='${myForm.abcType}' /> public final class myForm { private int abcType ; public int getAbcType() { return abcType; } public void setAbcType(int abcType) { this.abcType = abcType; } 如果我加入 name="abcType" <html:radio property="abcType" name="abcType" value="1" /> 就出現: Cannot find bean under name abcType 你需要在你的formbean中初始化一个值给这个属性 如 private int abcType=1; 但這個每一次出現都是第一個 呀. 我的目的是想出現之前選擇的哪一個值. |
|
返回顶楼 | |
发表时间:2006-01-18
如果我加入 name="abcType"
<html:radio property="abcType" name="abcType" value="1" /> 就出現: Cannot find bean under name abcType =================================== 看一下错误信息不就知道了吗?name里面应该放的是你的formBean的名字,而不是property的名。 |
|
返回顶楼 | |
发表时间:2006-01-18
香克斯 写道 如果我加入 name="abcType"
<html:radio property="abcType" name="abcType" value="1" /> 就出現: Cannot find bean under name abcType =================================== 看一下错误信息不就知道了吗?name里面应该放的是你的formBean的名字,而不是property的名。 哪個是formBean 的名字呀? 不是一樣嗎? 可否寫個例子給我嗎? |
|
返回顶楼 | |
发表时间:2006-01-21
<html:radio property="abcType" name="abcType" value="1" />
改成: <html:radio property="abcType" value="1" /> 去掉name="abcType" 属性 |
|
返回顶楼 | |
发表时间:2006-01-23
lingcm 写道 <html:radio property="abcType" name="abcType" value="1" />
改成: <html:radio property="abcType" value="1" /> 去掉name="abcType" 属性 我原本就是這樣 <html:radio property="abcType" /> |
|
返回顶楼 | |