利用ActionErrors的add方法从资源文件中读出message。对按钮A做判断,按钮B不做判断,按钮C只要提交就可以了。
例如:
<input type='button' onClick='location.href='/your.do?msg=A'" value="按钮A"/>
<input type='button' onClick='location.href='/your.do?msg=B'" value="按钮B"/>
<html:errors property="msg"/>
<input type='submit' value="按钮C"/>在ActionForm中:String msg = request.getParameter("msg");
ActionErrors errors = new ActionErrors();
if(msg.equals("A")){
errors.add("msg",new ActionError("err.msg"));
}在资源文件中:
err.msg=<input type="text" name="yourname"/>你看这样行不?
例如:
<input type='button' onClick='location.href='/your.do?msg=A'" value="按钮A"/>
<input type='button' onClick='location.href='/your.do?msg=B'" value="按钮B"/>
<html:errors property="msg"/>
<input type='submit' value="按钮C"/>在ActionForm中:String msg = request.getParameter("msg");
ActionErrors errors = new ActionErrors();
if(msg.equals("A")){
errors.add("msg",new ActionError("err.msg"));
}在资源文件中:
err.msg=<input type="text" name="yourname"/>你看这样行不?
解决方案 »
- the source attachment does not containthe source for the fileJdbcOdbcDrive.class
- 没完没了 按钮问题....
- 在同一个页面提交表单处理的问题?请大家来给解决..........
- javaBean的问题 菜鸟级
- 配置文件加上角色可以访问的资源就无法运行?
- Post方式,当数据过长时request.getParameterNames()居然得不到其它参数了?
- jQuery easyui 表单验证打开页面就验证
- Tomcat4.0与Oracle怎么建立连接池?建好后怎么测试?
- 我想根据用户的输入生成密码,请问一般如何生成
- 各位老兄,近来瞧瞧啊,问题简单,又有分拿啊,还有源代码啊!!!
- 通过jsp调用srvlet问题!!!急,
- 对用flash做的网站的一点疑惑
jsp中:
<html>
<script language="javascript">
function add_fun() {
document.form1.action.value="add";
document.form1.submit();
}
function del_fun() {
document.form1.action.value="del";
document.form1.submit();
}
function ok_fun() {
document.form1.action.value="ok";
document.form1.submit();
}
<script>
<body>
<form name="form1">
<input type="button" name="button1" value="add" onclick="add_fun();">
<input type="button" name="button2" value="del" onclick="del_fun();">
<input type="button" name="button3" value="ok" onclick="ok_fun();">
<input type="hidden" name="action" value="">
<%=HelperBean.getTextValue()%>
</form>
</body>
</html>
在.java中
写一个helperbean类(略)
在写一个event类
request(action)(具体的自己写)
if(action.equals("add")){
strText = getHelperbean()
strText += "<input type='text' name='text1' value=''>";
setHelperbean(自己写)
}
elseif(action.equals("del")){
删除一个
}else{
提交后的处理
}
只是个思路