请教各位大哥关于在struts结构的系统中使用javascript的问题。
本人是初学者,刚学javascript。在struts结构的页面中使用了这样的代码:
isDelete为复选框的属性 <html:multibox property="isDelete">
<script language="javascrit" >
<!--
function SelectAllClick(obj)
{
var oChks = document.getElementsByName("isDelete")
if(obj.checked)
for(var i = 0;i < oChks.length;i ++)
oChks[i].checked = true;
else
for(var i = 0;i < oChks.length;i ++)
oChks[i].checked = false;
}
//-->
</script>
<html:checkbox property="checkbox1" onclick="SelectAllClick(this)">全部选中</html:checkbox>
却出现了如下信息:
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: No getter method for property checkbox1 of bean org.apache.struts.taglib.html.BEAN
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.user.user_005flist_jsp._jspService(user_005flist_jsp.java:278)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.pz.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:121)
root cause
javax.servlet.jsp.JspException: No getter method for property checkbox1 of bean org.apache.struts.taglib.html.BEAN
org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:973)
org.apache.struts.taglib.html.CheckboxTag.isChecked(CheckboxTag.java:154)
org.apache.struts.taglib.html.CheckboxTag.doStartTag(CheckboxTag.java:129)
org.apache.jsp.user.user_005flist_jsp._jspx_meth_html_checkbox_0(user_005flist_jsp.java:516)
org.apache.jsp.user.user_005flist_jsp._jspService(user_005flist_jsp.java:237)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.pz.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:121)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.
--------------------------------------------
Apache Tomcat/5.0.30
是说 ActionForm 中没有获得 checkbox1 属性的方法吗?
好象是这样的:在JSP页面中使用struts标签一定在ActionForm中有对应的属性和属性方法。
那么
在JSP页面中使用struts标签的前提下,使用javascript。
怎样使用呢?
会不会在struts结构中使用javascript会有特别的一些配置呢?
需要注意一些什么呢?
请哪位大哥,教教小弟好吗? 先谢谢了。
[解决办法]
如果要用struts标签<html:checkbox>就要在对应FormBean里配一个属性checkbox1,及它的GETTER、SETTER方法
当然你也可以改成普通的复选框嘛
[解决办法]
javax.servlet.ServletException: No getter method for property checkbox1 of bean org.apache.struts.taglib.html.BEAN
象这种错误一般不外乎两种情况:
1、你的form中没有此属性的get方法
2、你页面上的<bean:xxxx>的属性名字写错了(发生的几率高一些)
[解决办法]
<html:checkbox property="checkbox1" onclick="SelectAllClick(this)">全部选中 </html:checkbox>
改为:
<label><input type="checkbox" name="checkbox1" onclick="SelectAllClick(this)" />全部选中</label>
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html