JSP javascript无法获取select控件中的值的问题"真心求教这是为什么?"
1、当select控件中option value=“1”时,ParamNames.jsp无法输出值;
String s = request.getParameter("categoryCd");
out.println(s);
2、当select控件中option value=“1++”或者字符串时,ParamNames.jsp就可以输出值
String s = request.getParameter("categoryCd");
out.println(s);
真心求教这是为什么?
<html>
<head>
<title>个人信息</title>
</head>
<body>
<form action="ParamNames.jsp" method="post" name="frmPersonal_Info">
<select name="categoryCd">
<option value = "1">1yue
<option value = "2">2yue
</selected>
</form>
</body>
</html>
------------------ParamNames.jsp---------------------
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%
request.setCharacterEncoding("GBK");
String s = request.getParameter("categoryCd");
out.println(s);
%>
------解决方案--------------------代码问题太大了点吧 </selected> select写错了吧
更改之后 我测试了 没问题。再有问题的话 你再发;
HTML的:
<body>
<form action="ParamNames.jsp" method="post" name="frmPersonal_Info">
<select name="categoryCd">
<option value="1">1yue
<option value="2">2yue
</select>
<input type="submit" value="提交1"/>
</form>
</body>
JSP的: <body>
This is my JSP page.
<br>
<%
request.setCharacterEncoding("GBK");
String s = request.getParameter("categoryCd");
out.println(s);
%>
</body>
------解决方案--------------------request.setCharacterEncoding("GBK");造成的