在线等---急

baihailong 2007-09-10 05:28:20
这是一个jsp。

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>

<html>
<head>


<title>My JSP 'search.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">

</head>
<script type="text/javascript" src="city.js"></script>
<body onload="Province();">
<form action="search.do" name="Frame" mathod="post">
<select id="province" onchange="City();"></select><select id="city" onchange="Area();"></select><select id="area"></select>
<select id="ps" onchange="Cs();"></select><select id="cs" onchange="As();"></select><select id="as"></select>
<br>
<input type="submit" name="submit" value="搜索">
</form>
</body>
</html>

提交的.do

package com.search.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
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.search.struts.form.SearchForm;

public class SearchAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
SearchForm searchForm = (SearchForm) form;// TODO Auto-generated method stub
HttpSession session=request.getSession();
String province=null;
String city=null;
String area=null;
String ps=null;
String cs=null;
String as=null;
province=request.getParameter("province");
city=request.getParameter("city");
area=request.getParameter("area");
ps=request.getParameter("ps");
cs=request.getParameter("cs");
as=request.getParameter("as");
System.out.print("省份"+province);
return mapping.findForward("ok");
}
}



Struts-config.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
<data-sources />
<form-beans >
<form-bean name="searchForm" type="com.search.struts.form.SearchForm" />

</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="searchForm"
input="/search.jsp"
name="searchForm"
path="/search"
scope="request"
type="com.search.struts.action.SearchAction" >
<forward name="ok" path="/ok.jsp"></forward>
<forward name="fail" path="/fail.jsp"></forward>
</action>
</action-mappings>

<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>


我在.do中输出province值为什么是空的呢?请帮忙看看一下
...全文
104 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
MySoftZone 2007-09-11
  • 打赏
  • 举报
回复
id="province"老大你这是id..request.getParameter("");
应该是name....
你加个name属性肯定可以得到..你改一下页面
<select id="province" name="province" onchange="City();">
MySoftZone 2007-09-11
  • 打赏
  • 举报
回复
兄弟我只能告诉你一个方法那就是在Javascript中测试一下你前端的值得到了结果没(你可以window.alert(document.getElementById("province").value);如果得到了值,在看看是否已经转发到Action中.我想应该是你前端没有得到结果造成的.

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧