一般的javascript都可以
怎么做我就不知道
不好意思
js我不会
怎么做我就不知道
不好意思
js我不会
解决方案 »
- 在SSH项目中,如何添加像导出excel,订单记录等等功能的
- 怎样用css或其他在jsp中让很多内容只显示几个字符
- struts-2.1.6的struts.xml一个配置问题
- 怎么理解session bean有状态和无状态这一概念?
- Map容器,一个测试小程序,无法调试正确。并帮我小注释下。
- 怎样理解组件和中间件概念
- 学web service 需要什么基础
- 帮忙看看映射哪里出问题了,hibernate映射有什么技巧?
- struts+hibernate如何处理数据库中的date字段?(mysql)
- 谁有JDBC驱动 for DBF????在线等。20分全给你了。
- 急!請大哥們幫個忙:struts上傳文件編碼問題!(若分不夠再加!)
- 周4 东软 来招人,要会jsp,servlet,struts,前面还好,struts不会,问问大家,假如我周1晚开始学,周1,2,3,这3天学struct,看什么书好
这个是HTML标签没有功能.
象你说的javascript与struts中的html标签的交互,它也可以;在struts中的html表单标签中写上type和name属性,然后你就可以在onsubmit调用了!
如html代码可以在dreamweaver中自动生成,而STRUTS中的html标签却不能自动生成,但是可以在自动生成的html标签中加上前缀html:不就行了;
还有html代码可以和JAVASCRIPT交互,STRUTS中的HTML标签同样可以啊
JS是同样可以在STRUTS的HTML标签里交互的。另外你会发现,STRUTS很多标签很方便的,可以省去一大堆的复杂代码,
但不用Struts的HTML标签,actionForm Action、还有FORM表单能影射在一起吗?那套框架是不是要修改了
免费招聘、求职。IT人工作的天堂。希望能够为大家所用。
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>waiting</title>
</head>
<body>
<table width="100%" height="34" >
<form name="girlsForm" method="post" action="<%=request.getContextPath()%>/girls/wait/action/noWaitAction.do" >
<input name="thisParm" type="hidden" value="OK"/>
<tr>
<td width="25%">用户名: <input name="userName" type="text" size="15"></td>
<td width="25%">密 码: <input name="password" type="password" size="15"> </td>
<td width="13%"> <input name="ok" type="submit" class="button-ok" value="登录"></td>
<td width="17%"><input name="cancle" type="reset" class="button-reset" value="重置"></td>
</tr>
</form>
</table>
</body>
</html>struts-config.xml:
<form-beans>
<form-bean name="girlsForm" type="com.girls.wait.form.GirlsForm" />
</form-beans>
<action-mappings>
<action name="girlsForm" path="/girls/wait/action/noWaitAction" type="com.girls.wait..action.NoWaitAction">
<forward name="noWait" path="/girls/wait/noWait.jsp" />
</action>
</action-mappings>
...
action:
package com.girls.wait..action;import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.girls.wait.form.GirlsForm;public class NoWaitAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse httpServletResponse) {
GirlsForm girlsForm = (GirlsForm)actionForm; String name = girlsForm.getName();
String password = girlsForm.getPassword(); String thisParm = request.getRequestParm("thisParm");//通过jsp页面hidden传过来的 return actionMapping.findForward("noWait");
}
}
<html:form action="/logon.do">
<html:text property="username"/>
</html:form>
以上标签生成的html代码为
<form name="logonForm" method="post" action="/hello/logon.do">
<!--logonForm是与logonAction关联的ActionForm //-->
<input type="text" name="username" value="">
</form>所以javascript可以用,毕竟因为javascript是在客户端执行,非容器端
document.forms["logonForm"].elements["username"]
或
document.forms["logonForm"].username
访问username文本框
struts的html标签,可以自动为表单初始化,封装提交ActionForm
<script LANGUAGE="JavaScript">
var index;
function changeIp(){
index=document.useBean.elements["user.host_name"].selectedIndex;
document.useBean.elements["user.host_ip"].selectedIndex=index;
}
</script><html:form method="post" action="/****.do"">
<html:select name="useBean" property="user.host_name" onchange="changeIp()">
----省略----
</html:select>
<html:select name="useBean" property="user.host_ip">
----省略----
</html:select>
</html:form>
既然打算用struts,就尽量提倡它的标签。