struts.xml<struts>
   <package name="default" extends="struts-default">
    <action name="login" class="loginAction" method="login">
      <result name="success">/EmpList.jsp</result>
      <result name="error">/login.jsp</result>
     </action>
     
     <action name="register" class="registerAction" method="insert">
      <result name="success">/login.jsp</result>
      <result name="error">/register.jsp</result>
      
     </action>
   </package>
  </struts>actionpublic class ShowInfoAction extends ActionSupport
{
  private ShowInfoService showInfoService;
  private HttpServletRequest request;
  private  PrimaryTab prim;
   private String tid;  private String tname;  public void setShowInfoService(ShowInfoService showInfoService) {
    this.showInfoService = showInfoService;
  }  private static final long serialVersionUID = -4113201327645756226L;  public String query() throws Exception {
    
    ActionContext context = ActionContext.getContext(); 
    Map dto = context.getParameters(); 
    System.out.print(showInfoService.queryById(prim));
    if(showInfoService.queryById(prim).equals(dto.get("tid")) || showInfoService.queryByName(prim).equals(dto.get("tname"))){
      request.setAttribute("tid", tid);
      request.setAttribute("tname", "tanme");
    
      return SUCCESS;
      
    }
    return ERROR;
    
  }
  public PrimaryTab getPrim() {
    return prim;
  }  public void setPrim(PrimaryTab prim) {
    this.prim = prim;
  }  public String getTid() {
    return tid;
  }  public void setTid(String tid) {
    this.tid = tid;
  }  public String getTname() {
    return tname;
  }  public void setTname(String tname) {
    this.tname = tname;
  }}jsp
<%@ page language="java" contentType="text/html; charset=windows-31j"
    pageEncoding="UTF-8"%>
<%@page import="org.apache.struts2.ServletActionContext"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/struts-tags" prefix="s" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-31j">
<title></title>
   <script type="text/javascript"></script></head><body>
<s:form name="form1" action="query.action">
<TABLE width="100%" align="center" cellpadding="0" cellspacing="0" border="0" ><TR>
<TD>
    <table  width="100%" align="center" cellpadding="1" cellspacing="1" border="0" >   
     <tr>
       <td colspan="20"  height="20">
         Query Condition
       </td>
    </tr>
      <tr >
        <td>table ID
        <input type="text" name="tid" />
        </td>
        <td>table name
        <input type="text" name="tname" /></td>
        <td><input type="submit" value="query" ></td>
      </tr>
    </table>
     
     
       <h2></h2>
     
     <div  style='width: 620px;margin: 0 auto; border: 0px solid gray; padding: 0px  '>
    <table align='center' cellpadding='0' cellspacing='0' width='600' border='1'>
     <tr>
     <td align='center'></td>
     <td align='center'>TABLE ID</td>
     <td align='center'>TABLE NAME</td>
     </tr>
     
     <s:iterator value="prim">
     <tr>
     <td align='center'><input type="radio"  checked="checked"></td>
     <td align='center'><%=request.getAttribute("tid")%></td>
     <td align='center'><%=request.getAttribute("tname")%></td>
     </tr>
     </s:iterator>
     </table>
     </div>
    
   
</TD>  
</TR>  
</TABLE></s:form>
      
</body>
</html>
DAOimplpackage com.jbridge.dao;/*import java.util.ArrayList;*/
import java.util.List;import org.springframework.jdbc.core.JdbcTemplate;import com.jbridge.beans.PrimaryTab;public class ShowInfoDaoImpl implements ShowInfoDao
{
  private JdbcTemplate jdbcTemplate;
  
   public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
  }  public List queryById(PrimaryTab prim) throws Exception {
  /*  List allData = new ArrayList();*/
    
    String sql = "SELECT TABLE_ID,TABLE_NAME FROM T_BZXX WHERE TABLE_ID=?";
   
     return jdbcTemplate.queryForList(sql, new Object[]{prim.getTABLE_ID(),prim.getTABLE_NAME()});
  
   
  }  public List queryByName(PrimaryTab prim) throws Exception {
    String sql = "SELECT TABLE_ID,TABLE_NAME FROM T_BZXX WHERE TABLE_NAME like %?%";
    
    
    
    return jdbcTemplate.queryForList(sql, new Object[]{prim.getTABLE_ID(),prim.getTABLE_NAME()});
  }}不知道怎么回事就是不好用,大家帮忙看看是怎么回事,从数据库拿不到值,越快越好,急!!!

解决方案 »

  1.   

    比如:
    <action path="/user"
    type="org.springframework.web.struts.DelegatingActionProxy"
    name="userForm" parameter="method" scope="request"
    validate="false">
    <forward name="success" path="/jsp/user/userList.jsp" />
    <forward name="updateuser" path="/jsp/user/updateUser.jsp" />
    <forward name="selectuser" path="/jsp/user/selectUser.jsp" />
    <forward name="adduserfail" path="/jsp/user/addUserFail.jsp" />
    <forward name="login" path="/jsp/main.jsp" />
    </action>