呵呵,楼主,刚才我看了struts的文档,html:checkbox里面好像没有这个属性呢,在jsp中好像是checked = true
解决方案 »
- hibernateTemplate不能删除一个实体
- java 内存地址 通过 jni 能获得到吗 在线等 100分
- 跪求帮助 Spring mvc <mvc:annotation-driven /> 报错
- 关于jdk版本的问题
- httpservletrequest.setattribute和servletrequest.setattribute的区别
- j2ee从linux下载文件
- 请帮忙优化一下这段代码,请高手一定要帮忙,我会千万分感谢的!
- JAVA程序调用LINUX命令获取版本信息并输出到文件怎么做
- jsp+servlet+bean做的一个非常具体处理一件事情的东西,但是要求这个过程中遇到的问题,比如文件找不到。。最后都通过一个页面报告给客户
- 关于hibernate5.2.4的一个问题:每次运行hibernate都会创建表
- jbuilder9 部分项目不可用
- 看了几张weblogic,tomcat贴的拙见,请指点
我也查过,没找到to:bdsc
我在fromBean里给属性设置了值,但显示时还是没选中还有其它办法吗?
期待你的高论!
在页面的最后,</html>之前,加上:document.formname.checkname.checked=true;
在action中将first属性付值为123就可以了。
如果不指定value:
<html:checkbox property="first"/>
那么付值为on就可以。
页面的checkBox就会被选中
<html:html>
<head>
<title></title>
<html:base/>
</head>
<body bgcolor="white">
<html:form action="/wcAction.do" method="post">
<html:text property="mybeanvariable1" />
<html:checkbox property="chec" value="123" />
<html:checkbox property="chec" value="444" />
<html:submit value="提交" />
<html:reset value="重写" />
</html:form>
</body>
</html:html>/////////////
在FormAction中: private String chec="123"; //默认选中第一个check
public String getChec()
{
return (this.chec);
} public void setChec(String chec)
{
this.chec=chec;
}
///////////////////////////////
在Action中:
//函数定义:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
// Extract attributes and parameters we will need
Locale locale = getLocale(request);
MessageResources messages = getResources(request);
HttpSession session = request.getSession();
wcForm m_wcForm = (wcForm) form;
String chec=m_wcForm.getChec();
if(chec.equals("123"))
{
m_wcForm.setChec("123");
}
else
{ m_wcForm.setChec("444");
}
................
/////////////////////////////
第一次运行时默认选中了第一个check可实现两个checkbox的选中一个。本例在JSPStudio中试运行通过。