<input type="button" value="年账务查询" onclick="document.location='yearAcc.action?module=4'" />
这句话什么意思?主要是不知道按钮响应事件怎么执行。
onclick="document.location='yearAcc.action?module=4'"  和Java代码怎么联系的?

解决方案 »

  1.   

    onclick 是鼠标点击事件,单击时候会触发。触发后执行 
    document.location='yearAcc.action?module=4'
    这句是把整个页面转向到 
    yearAcc.action 
    并且带上一个参数 module = 4; 
    这相当于向 你的action提交请求,通信就此开始。
      

  2.   

    这句跟java没什么联系
    只是一个js的url跳转函数 跳转到location后面的地址
    跟form中的action一样
      

  3.   


    谢谢!  那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>
      

  4.   

    jsp可以连接数据库,那怎么实现按下Button,从数据库读相应数据显示到页面?
      

  5.   

    那个yearAcc.action就是struts2的请求路径,通过这个可以找到处理本请求的action了。
      

  6.   

    在struts中的配置文件中有yearAcc.action 这个东东,可能是这样写的path=yearAcc,然后你会找到对应的servlet,然后会有访问数据库的代码,再然后就会把从数据库中的得到的代码显示到页面。
      

  7.   

    onclick="document.location='yearAcc.action?module=4'"
    onclick是点击事件
    document.location是页面转发,转发的地址是yearAcc.action是一个Action在这个action中要带入一个值是module=4还可以在带入数据在后面使用&来带入数据这个也可以叫做URL重写
      

  8.   

    找到了,代码如下:
    <?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标签什么意思?参数和标签中间的内容。
      

  9.   

    谁有简单的用Java、structs和sql写的例子吗?我自己研究也行,有的传一个。
    邮箱:[email protected]。非常感谢!
      

  10.   


    这里的 result 就相当于 struts 中的 forward 属性  
      

  11.   

    看来你才开始学JSP/servlet啊 多看看这方面资料吧。这个是JAVAEE的基础。