<input type="button" value="年账务查询" onclick="document.location='yearAcc.action?module=4'" />
这句话什么意思?主要是不知道按钮响应事件怎么执行。
onclick="document.location='yearAcc.action?module=4'" 和Java代码怎么联系的?
这句话什么意思?主要是不知道按钮响应事件怎么执行。
onclick="document.location='yearAcc.action?module=4'" 和Java代码怎么联系的?
解决方案 »
- hibernate 查询缓存问题
- 【请教】不重启tomcat重新加载xml配置文件
- struts2与spring整合问题
- 求Java回车键监听器代码
- jsp项目运行时出现的问题
- JSP打印产品、组件请教
- struts action中如何得到jsp中的action参数和target参数
- Tomcat321中有没有办法知道JVM使用了多少内存?如何给JVM分配指定大小的内存?
- struts自带的例子有个action.xml,有什么用,在什么地方调用呢
- weblogic中应用程序发布成功,但启动失败,求助
- 在web上发邮件连接不上smtp服务器 在客户端上能发邮件这是什么原因
- dom4j 的属性问题
document.location='yearAcc.action?module=4'
这句是把整个页面转向到
yearAcc.action
并且带上一个参数 module = 4;
这相当于向 你的action提交请求,通信就此开始。
只是一个js的url跳转函数 跳转到location后面的地址
跟form中的action一样
谢谢! 那yearAcc.action表示什么?全部的jsp代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<head>
</head> <body bgcolor="#ccddee" link="#000066" vlink="#0066FF" alink="#99FF00">
<form action="monthAcc.action?module=4" method="post">
<table width="100%">
<tr>
<td width="15%">
<input type="button" value="月账务查询"
onclick="document.location='monthAcc.action?module=4'" />
</td>
<td width="15%">
<input type="button" value="年账务查询"
onclick="document.location='yearAcc.action?module=4'" />
</td>
<td width="55%" align="right">
<s:select list="#{'2008':'2008','2007':'2007'}" name="year"
theme="simple" />
年
<s:select
list="#{'12':'12','11':'11','10':'10','09':'9','08':'8','07':'7','06':'6','05':'5','04':'4','03':'3','02':'2','01':'1'}"
name="month" theme="simple" />
月
</td>
<td width="0">
</td>
<td width="15%" align="left">
<input type="submit" value=" 查询 " />
</td>
</tr>
</table>
</form> <center>
<table width="100%" border=1 align="center" cellpadding="0"
cellspacing="0" bgcolor="#ccddee">
<tr>
<td colspan="3" align="left">
查询日期:
<s:property value="year" />
年
<s:property value="month" />
月
</td>
</tr>
<tr>
<td align="center" width="34%">
服务器
</td>
<td align="center" width="33%">
总计(单位:小时)
</td>
<td align="center" width="33%">
详细清单
</td> </tr>
<s:iterator value="monthAccs" status="rowstatus">
<tr <s:if test="#rowstatus.odd == true">bgcolor="white"</s:if>>
<td align="center">
<s:property value="monthAccs[#rowstatus.index][1]" />
</td>
<td align="center">
<s:property value="monthAccs[#rowstatus.index][2]" />
</td>
<td align="center">
<a
href="monthAccDetail.action?module=4&yearMonth=<s:property value="monthAccs[#rowstatus.index][0]"/>&labIp=<s:property value="monthAccs[#rowstatus.index][1]"/>">详细清单</a>
</td>
</tr>
</s:iterator>
</table>
</center> </body>
</html>
onclick是点击事件
document.location是页面转发,转发的地址是yearAcc.action是一个Action在这个action中要带入一个值是module=4还可以在带入数据在后面使用&来带入数据这个也可以叫做URL重写
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">//这个是注释吗?<struts> <package name="account" namespace="/account"
extends="struts-default">//extends什么意思 <!-- 月账务列表 -->
<action name="monthAcc"
class="com.netctoss.account.action.MonthAccAction">
<result name="success" type="dispatcher">//result这个标签什么意思?
monthAcc.jsp
</result>
</action> <!-- 月账务明细 -->
<action name="monthAccDetail"
class="com.netctoss.account.action.MonthAccAction" method="detail">
<result name="success" type="dispatcher">
monthAccDetail.jsp
</result>
</action> <!-- 年账务列表 -->
<action name="yearAcc"
class="com.netctoss.account.action.YearAccAction">
<result name="success" type="dispatcher">
yearAcc.jsp
</result>
</action> <!-- 年账务明细 -->
<action name="yearAccDetail"
class="com.netctoss.account.action.YearAccAction" method="detail">
<result name="success" type="dispatcher">
yearAccDetail.jsp
</result>
</action>
</package></struts>result标签什么意思?参数和标签中间的内容。
邮箱:[email protected]。非常感谢!
这里的 result 就相当于 struts 中的 forward 属性