我的页面 是
tiaojia.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
String path=request.getContextPath();
%>
<%@ include file="/taglibs.jsp"%>
<%@ include file="/checkSession.jsp"%>
<html>
<head>
<title>加中科技医院信息系统</title>
<link href="inc/style.css" rel="stylesheet">
</head>
<body >
<form action="tiaojiaAction.do" method="post">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" height="100" class="tableborder">
<tr>
<th class="th" height="30" colspan="7">调价盈亏统计</th>
</tr>
<tr align="center">
<td class="row" height="30" >时间段:</td>
<td class="row" height="30" ><input name="timefrom" type="text" style="width:100px">至</td>
<td class="row" height="30" ><input name="timeto" type="text" style="width:100px"></td>
<td class="row" height="30" >消耗品名称:</td>
<td class="row" height="30" ><input name="customername" type="text" style="width:100px"></td>
</tr>
<tr align="center">
<td class="row" height="30" >消耗品分类:</td>
<td class="row" height="30">
<select name="customersort" style="width:100px" >
<option value="xiyao" selected="selected">xiyao</option>
</select>
</td>
<td class="row" height="30">
<input type="submit" name="Submit" value="统计" />
</td>
<td class="row" height="30">
<input type="submit" name="Submit" value="统计全部" />
</td>
<td class="row" height="30">
<input type="submit" name="Submit" value="打印" />
</td>
</tr>
<tr>
<td colspan="7">
<table align=center border="0" cellspacing="1" cellpadding="0" class="tableborder" width="100%">
<tr align="center">
<td class="th" height="30" >调价日期</td>
<td class="th" height="30" >名称</td>
<td class="th" height="30" >规格</td>
<td class="th" height="30" >厂家</td>
<td class="th" height="30" >单位</td>
<td class="th" height="30" >调价数量</td>
<td class="th" height="30">原零售价</td>
<td class="th" height="30" >零售金额</td>
<td class="th" height="30" >现零售价</td>
<td class="th" height="30" >零售金额</td>
<td class="th" height="30" >调价盈亏</td>
</tr>
<logic:present name="list">
<logic:iterate id="element" name="list">
<tr align="center">
<td class="row" height="30" ><bean:write name='element' property='timefrom'/></td>
<td class="row" height="30" ><bean:write name='element' property='timeto'/></td>
<td class="row" height="30" ><bean:write name='element' property='customername'/></td>
<td class="row" height="30" ><bean:write name='element' property='customername'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='customername'/></td>
<td class="row" height="30" ><bean:write name='element' property='timefrom'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='timefrom'/></td>
</tr>
</logic:iterate>
</logic:present>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
我的struts的配置文件是<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
<data-sources />
<form-beans >
<form-bean name="userloginForm" type="com.cader.web.form.UserloginForm" />
<form-bean name="tiaojiaForm" type="com.cader.web.form.TiaojiaForm" />
</form-beans> <global-exceptions />
<global-forwards >
<forward name="sessionFailure" path="/checkSession.jsp" />
</global-forwards>
<action-mappings >
<action attribute="userloginForm" input="/userlogin.jsp" name="userloginForm" parameter="modelname" path="/userlogin" scope="request" type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="success" path="/h_index.jsp" />
<forward name="failure" path="/userlogin.jsp" />
<forward name="info" path="/information.jsp" />
</action>
<action path="/modleflagFind" type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="menuGo" path="/menu.jsp" />
<forward name="failGo" path="/fail.jsp" />
</action>
<action input="/tiaojia.jsp" name="tiaojiaForm" path="/tiaojiaAction" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" validate="true">
<forward name="success" path="/tiaojia.jsp" />
<forward name="failure" path="/failure.jsp" />
</action>
</action-mappings> <message-resources parameter="ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContextT.xml,/WEB-INF/applicationContextB.xml,/WEB-INF/applicationContextA.xml,/WEB-INF/applicationContextF.xml,/WEB-INF/applicationContextC.xml,/WEB-INF/applicationContextE.xml,/WEB-INF/applicationContextD.xml,/WEB-INF/applicationContextG.xml,/WEB-INF/applicationContextX.xml,/WEB-INF/applicationContextH.xml,/WEB-INF/applicationContext.xml"/>
</plug-in>
</struts-config>
tiaojia.jsp
<%@ page language="java" import="java.util.*" pageEncoding="GB2312"%>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
String path=request.getContextPath();
%>
<%@ include file="/taglibs.jsp"%>
<%@ include file="/checkSession.jsp"%>
<html>
<head>
<title>加中科技医院信息系统</title>
<link href="inc/style.css" rel="stylesheet">
</head>
<body >
<form action="tiaojiaAction.do" method="post">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" height="100" class="tableborder">
<tr>
<th class="th" height="30" colspan="7">调价盈亏统计</th>
</tr>
<tr align="center">
<td class="row" height="30" >时间段:</td>
<td class="row" height="30" ><input name="timefrom" type="text" style="width:100px">至</td>
<td class="row" height="30" ><input name="timeto" type="text" style="width:100px"></td>
<td class="row" height="30" >消耗品名称:</td>
<td class="row" height="30" ><input name="customername" type="text" style="width:100px"></td>
</tr>
<tr align="center">
<td class="row" height="30" >消耗品分类:</td>
<td class="row" height="30">
<select name="customersort" style="width:100px" >
<option value="xiyao" selected="selected">xiyao</option>
</select>
</td>
<td class="row" height="30">
<input type="submit" name="Submit" value="统计" />
</td>
<td class="row" height="30">
<input type="submit" name="Submit" value="统计全部" />
</td>
<td class="row" height="30">
<input type="submit" name="Submit" value="打印" />
</td>
</tr>
<tr>
<td colspan="7">
<table align=center border="0" cellspacing="1" cellpadding="0" class="tableborder" width="100%">
<tr align="center">
<td class="th" height="30" >调价日期</td>
<td class="th" height="30" >名称</td>
<td class="th" height="30" >规格</td>
<td class="th" height="30" >厂家</td>
<td class="th" height="30" >单位</td>
<td class="th" height="30" >调价数量</td>
<td class="th" height="30">原零售价</td>
<td class="th" height="30" >零售金额</td>
<td class="th" height="30" >现零售价</td>
<td class="th" height="30" >零售金额</td>
<td class="th" height="30" >调价盈亏</td>
</tr>
<logic:present name="list">
<logic:iterate id="element" name="list">
<tr align="center">
<td class="row" height="30" ><bean:write name='element' property='timefrom'/></td>
<td class="row" height="30" ><bean:write name='element' property='timeto'/></td>
<td class="row" height="30" ><bean:write name='element' property='customername'/></td>
<td class="row" height="30" ><bean:write name='element' property='customername'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='customername'/></td>
<td class="row" height="30" ><bean:write name='element' property='timefrom'/></td>
<td class="row" height="30" ><bean:write name='element' property='customersort'/></td>
<td class="row" height="30" ><bean:write name='element' property='timefrom'/></td>
</tr>
</logic:iterate>
</logic:present>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
我的struts的配置文件是<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
<data-sources />
<form-beans >
<form-bean name="userloginForm" type="com.cader.web.form.UserloginForm" />
<form-bean name="tiaojiaForm" type="com.cader.web.form.TiaojiaForm" />
</form-beans> <global-exceptions />
<global-forwards >
<forward name="sessionFailure" path="/checkSession.jsp" />
</global-forwards>
<action-mappings >
<action attribute="userloginForm" input="/userlogin.jsp" name="userloginForm" parameter="modelname" path="/userlogin" scope="request" type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="success" path="/h_index.jsp" />
<forward name="failure" path="/userlogin.jsp" />
<forward name="info" path="/information.jsp" />
</action>
<action path="/modleflagFind" type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="menuGo" path="/menu.jsp" />
<forward name="failGo" path="/fail.jsp" />
</action>
<action input="/tiaojia.jsp" name="tiaojiaForm" path="/tiaojiaAction" scope="request" type="org.springframework.web.struts.DelegatingActionProxy" validate="true">
<forward name="success" path="/tiaojia.jsp" />
<forward name="failure" path="/failure.jsp" />
</action>
</action-mappings> <message-resources parameter="ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContextT.xml,/WEB-INF/applicationContextB.xml,/WEB-INF/applicationContextA.xml,/WEB-INF/applicationContextF.xml,/WEB-INF/applicationContextC.xml,/WEB-INF/applicationContextE.xml,/WEB-INF/applicationContextD.xml,/WEB-INF/applicationContextG.xml,/WEB-INF/applicationContextX.xml,/WEB-INF/applicationContextH.xml,/WEB-INF/applicationContext.xml"/>
</plug-in>
</struts-config>
<form action="/tiaojiaAction.do" method="post">
你的后台就没有什么错误提示信息?
--》
<html:form action="tiaojiaAction.do" method="post">
<form action="/你的应用工程名称/tiaojiaAction.do" method="post">
<html:form action="/tiaojiaAction">
我的TiaojiaAction.java的代码
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.cader.web.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;import com.cader.business.SelectTiaojiaInterface;
import com.cader.web.form.TiaojiaForm;import java.util.List;
/**
* MyEclipse Struts
* Creation date: 03-27-2007
*
* XDoclet definition:
* @struts.action validate="true"
* @struts.action-forward name="success" path="/tiaojia.jsp"
* @struts.action-forward name="failure" path="/failure.jsp"
*/
public class TiaojiaAction extends Action {
/*
* Generated Methods
*/
SelectTiaojiaInterface tiaojiaBean=null; public void setTiaojiaBean(SelectTiaojiaInterface tiaojiaBean) {
this.tiaojiaBean = tiaojiaBean;
} /**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
String timefrom=null;
String timeto=null;
String customername=null;
String customersort=null;
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
// TODO Auto-generated method stub
try{
System.out.println("11111111111111111111111111111111111111111111111111111111111111111111111111111111");
TiaojiaForm tiaojiaForm=(TiaojiaForm)form;
timefrom=new String(tiaojiaForm.getTimefrom().getBytes("iso8859-1"),"GB2312");
timeto=new String(tiaojiaForm.getTimeto().getBytes("iso8859-1"),"GB2312");
customername=new String(tiaojiaForm.getCustomername().getBytes("iso8859-1"),"GB2312");
customersort=new String(tiaojiaForm.getCustomersort().getBytes("iso8859-1"),"GB2312");
}
catch (Exception e){}
System.out.println("启始时间是:"+timefrom);
System.out.println(timeto);
System.out.println(customername);
System.out.println(customersort);
List result= this.tiaojiaBean.doselectTiaojia(timefrom,timeto,customername,customersort);
if((result==null)||(result.size()==0))
{
return mapping.findForward("failue");
}
else
{
request.setAttribute("list", "result");
return mapping.findForward("success");
}
}
}
<html:form action="/tiaojiaAction.do">
<html:text property="timefrom"/>
....
</html:form>
String timefrom = request.getParameter("timefrom");
11111111111111111111111111111111111111111111111111111111111111111111111111111111
如果不用<html:form>用的是html的<form>后台接收数据的应该用
String timefrom = request.getParameter("timefrom");
在Action里面直接接收ActionForm的话就要把标签改了,不改就如上面的了,
====>
<html:form action="tiaojiaAction.do">
不行吗?
在页面 上用普通的标签就行,也能往action里面传,我就吧action里的Form 该成了actionForm。
就ok了,还是谢谢各位了