<td>
<select name="contractflag" id="select">
<option value="1">采购</option>
<option value="2">销售</option>
<option value="3">进出口</option>
</select>
</td>
提交怎样在action中接收得到"1"

解决方案 »

  1.   

    String contractflag = request.getParameter("contractflag");
      

  2.   

    提交到action里 用 String contractflag = request.getParameter("contractflag");
      

  3.   

    引用
    提交到action里 用 String contractflag = request.getParameter("contractflag");如果是struts2 就在action里面定义 private String contractflag;添加get and set
      

  4.   

    你是不是要取到 文本 比如采购 销售 进出口     这些?
    如果是的话 要用js才可以代码如下:
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
           
       
        
        <title>My JSP 'select.jsp' starting page</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      
      <body>  <form action="select.action" id="form1" name="form1" method="post" id="f">
      <table>
      <tr>
      <td>
    <select name="contractflag" id="select" onchange="document.getElementById('sel_text').value = options[selectedIndex].text">
    <option value="1">采购</option>
    <option value="2">销售</option>
    <option value="3">进出口</option>
    </select>
    <input name="selname" type="hidden" id="sel_text" > 
    </td>
      
      </tr>
      </table>
    <input type="submit" value="submit">
      </form>  </body>
    </html>
    action直接取到就可以 然后自己该怎么处理就怎么处理package com.pbmis.action;import com.opensymphony.xwork2.ActionSupport;public class SelectAction extends ActionSupport {
    private String contractflag; private String selname; public String execute() {
    System.out.println(contractflag);
    System.out.print(selname);
    return "success";
    } public String getContractflag() {
    return contractflag;
    } public void setContractflag(String contractflag) {
    this.contractflag = contractflag;
    } public String getSelname() {
    return selname;
    } public void setSelname(String selname) {
    this.selname = selname;
    }
    }