JSP: 页面:

<%@ page language="java"  pageEncoding="GBK"%>
<%@taglib prefix="s"  uri="/struts-tags"%>

<%
   request.setAttribute("path",request.getContextPath());
%>
<html>
  <body>
  <center>
    <s:form action="borrowBook.action">
  <table>
  <tr>
  <th>序号</th>
  <th>书号</th>
  <th>书名</th>
  <th>用户</th>

</tr>
  <s:iterator value="abook" status="st" >
  <!-- 隐藏域 得到 用户的id -->
  <input type="hidden" name="bookId" value="<s:property value="id"/>" >
<!-- 此处 写一个隐藏域,name为bookId  要想将该值(在提交表单时)传给 对应的action  应该在目标action中 定义一个属性 为 bookId  也就是hidden 中 name 的值! (private Long bookId;)并且也提供get/set方法-->
  <tr>
  <td><s:property value="#st.count"/></td>
  <td><s:property value="book.bno"/></td>
  <td><s:property value="bname"/></td>
  <td>
 
  <s:select name="userId"
            list="userNames"
    listKey="id"
    listValue="uname"
    id="selectid"
    emptyOption="-1"
    headerValue="选择用户"
  ></s:select>
 
  </td>
 
  </tr>
  </s:iterator>
  </table> 
  <s:submit value="提交"></s:submit>
    </s:form>
<input type="button" value="submit" onclick="get()"/>
   
  </center>
  </body>

</html>

action:类:
public  class BookAction{
      private Long bookId;
     /**
此处的bookId必须和jsp页面的要传向Action的 值的name 值相同
*/
      public Long getBookId() {
return bookId;
}

public void setBookId(Long bookId) {
this.bookId = bookId;
}
    public String borrowBook(){
    System.out.println("JSP   bookId:  "+bookId);
    }

}

将 jsp 页面的值 传到struts2 action中(不是表单中的值)的更多相关文章

  1. jsp页面使用el 按key获取map中的对应值

    jsp页面使用el 按key获取map中的对应值 转自:<jsp页面使用el 按key获取map中的对应值>地址:http://blog.csdn.net/baple/article/de ...

  2. 在vue中下拉框切换事件中改新建表单中的一个值,页面不显示

    事件中改新建表单中的一个值,页面不显示,当另一个对象值发生改变时,这个页面上的值才会显示 由于新建表单是弹窗,在弹出时会重新给每个字段重新赋值,在赋值时没给这个字段赋值(常见新加功能时,加了一个字段, ...

  3. struts2 中属性驱动(其实就是struts2 action 中处理 request 的参数【old 方式servlet api 封装数据到javabean中(or beanutils)】),这里属性驱动是新方式

    1.属性驱动 a\  一般的set public class UserAction extends ActionSupport { private String username; private S ...

  4. jQuery中设置form表单中action值与js有什么不同。。。。

    jQuery中设置form表单中action值与js有什么不同.... HTML代码如下: <form action="" method="post" i ...

  5. 预定义的 $_POST 变量用于收集来自 method="post" 的表单中的值

    PHP $_POST 变量 在 PHP 中,预定义的 $_POST 变量用于收集来自 method="post" 的表单中的值. $_POST 变量 预定义的 $_POST 变量用 ...

  6. 预定义的 $_GET 变量用于收集来自 method="get" 的表单中的值

    PHP $_GET 变量 在 PHP 中,预定义的 $_GET 变量用于收集来自 method="get" 的表单中的值. $_GET 变量 预定义的 $_GET 变量用于收集来自 ...

  7. jQuery中设置form表单中action的值的方法

    下面介绍在jQuery中设置form表单中action的值的方法. $("#myFormId").attr("action", "userinfo.s ...

  8. jQuery中设置form表单中action值的方法

    jQuery中设置form表单中action值的方法 (2011-03-17 10:18:19) 转载▼ 标签: 杂谈   html代码: <form id="myFormId&quo ...

  9. layui获取子集表单中的值,关闭父级弹窗

    js代码 var GetParams = function(url,bool) { try { if(bool){ var index = url.indexOf('?'); url = url.ma ...

随机推荐

  1. How to configure connectingstrings in Web.config

    先来看一下默认的连接SQL Server数据库配置<connectionStrings>   <add name="LocalSqlServer" connect ...

  2. 关于switch的思考和总结

    1.通常每个case的末尾都应该加个break; 否则会default分支也会被执行 var score = 40;switch (score){case 50:console.log('50');/ ...

  3. Qt 继承QWidget setstylesheet解决

    void myMainWidget::paintEvent(QPaintEvent * e) { QStyleOption opt; opt.init(this); QPainter p(this); ...

  4. Sicily-1152 回溯算法

    一.题意: 走日字,每个位置都有有8种新位置,从起点开始刚好过29步遍历其他位置一遍. 二.代码 // // main.cpp // Sicily-1152 回溯算法 // // Created by ...

  5. Sicily-1028

    一.        题意: 算出汉诺塔移动序列中对应位置的号码,数据规模很大,所以不能单纯递归,而是要找出汉诺塔序列的规律. 二.        汉诺塔数列 为了得出最少的移动步数,当n为偶数时,最上 ...

  6. Cocos2d-x init() 和 onEnter() 区别

    在Cocos2d-x中经常碰到 init() 和 onEnter() init()和onEnter()这两个方法都是CCNode的方法. 1.二者的执行顺序是:先init() 后onEnter(). ...

  7. Android4.3模拟器界面中右侧菜单按钮无法使用问题解决办法

    开发环境:笔记本电脑Windows2008+MyEclipse 10+Android4.3 问题描述:运行或者调试Android项目时,发现模拟器中右侧Menu按钮无法点击,截图如下: 查看在Andr ...

  8. QQ聊天原理初识

    1:qq之间文件的传输是通过p2p通信进行的. 2:qq之间的表情发送实际上就是文字的发送,是client再接受到文字之后在本地自己进行转换 3:qq之间的通信既能够通过udp也能够通过Tcp 尽管u ...

  9. IPv4头部结构具体解释

    IPv4头部结构具体解释 下面为书中原文摘录: $(function () { $('pre.prettyprint code').each(function () { var lines = $(t ...

  10. LeetCode: Sum Root to Leaf Numbers [129]

    [题目] Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a n ...