猿问

跪求大神幫解多個下拉選單傳值給mysql的使用錯誤的request.getParameter

想把下拉选单传送给mysql但是一值报错请大神帮忙解决

====================================


String Channel = request.getParameter(“Channel”);


String WEEkDate = request.getParameter(“WeekDate”);


String [] hobby = request.getRequestDispatcher(Channel,WEEkDate);<<<这里错误


=================================================


想询问一下要怎样才能接收String Channel follow String WEEkDate让 hobby接收



下面是  jsp 上的代碼  

======================================

<form method="post" action="vfvf.jsp">

<table width=500 align=center>

<tr>

<td align = center>商家:


<select name =“Channel”>


<option value =“上海商家”>上海商家


<option value =“京东网店”>京东网店


<td align = center>周:

<select name="WeekDate">

<option value="0304">0304

<option value="0305">0305

<option value="0401">0401

<option value="0403">0403

</select>

<input type="submit" value="ok">

</table>

</form>

<hr>

<%

request.setCharacterEncoding("utf-8");

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

String   WEEkDate = request.getParameter("WeekDate") ;

String[] hobby = request.getRequestDispatcher(Channel,WEEkDate);     <<<这里错误

ResultSet rs = Songlist1.ktvChannelWeekDate(Channel ,WEEkDate);




================================================



java接收内容
==========================
public static ResultSet ktvChannelWeekDate(String Channel,String WEEkDate)
{
String url="jdbc:mysql://localhost:3306/billboard?useUnicode=true&characterEncoding=utf-8";
String user="root";
String password="1234";
String sql="select * from ktvview where Channel='"+Channel+"'amd  WeekDate='"+WEEkDate+"'  order by id";ResultSet rs=null;

try
{
  Class.forName("com.mysql.jdbc.Driver");  
  Connection conn=DriverManager.getConnection(url, user, password);    
  Statement st=conn.createStatement();rs=st.executeQuery(sql);
  } catch (ClassNotFoundException ex) {  
  System.out.println("no driver");
  }catch(SQLException e)
  {
     System.out.println("no connection");
     }
     return rs;
     }

qq_詁詁木_0
浏览 521回答 1
1回答

Abby_lrwei

第三行代码的标点符号是中文的,我复制到notepad看是这样的,不知道是您写错了还是复制过来慕课系统做了转换
随时随地看视频慕课网APP
我要回答