JSP下拉框选择了一个值可以把值存到数据库 做一个新增页面,里面有个下拉框,下拉框是获取数据库的数据。
当在下拉框里选择一个值后点击保存,它能够把这个值存储到数据库里,怎写JSP代码呢<body><%List<BookInfo>bookInfos=(List<BookInf...
当在下拉框里选择一个值后点击保存,它能够把这个值存储到数据库里,怎写JSP代码呢
<body>
<%
List<BookInfo> bookInfos = (List<BookInfo>)request.getAttribute("bookInfos");
if(bookInfos==null){
bookInfos=new ArrayList<BookInfo>();
}
%>
<table>
<caption>新增图书类别列表</caption>
<tr>
<td>图书名称:</td>
<td><input name="bookName" size="40"></td>
</tr>
<tr>
<td>图书类别编号下拉框:</td>
<td>
<select name="course">
<%
for(BookInfo bookInfo : bookInfos){%>
<option value=<%=bookType.getBookTypeId()%>><%=bookType.getBookTypeId()%></option> <% }
%></select>
</td>
<tr>
<td><input type="submit" name="submit" value="保存"></td>
</tr>
</table>
</form>
</body>
</html>
下拉框的值是取另一个表的数据
我这样写填写信息后保存就弹错了
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:415)
java.lang.Integer.parseInt(Integer.java:497)
com.wangwang.servlet.bookInfo.SaveBookInfoServlet.doPost(SaveBookInfoServlet.java:40)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.
这个是图 展开
<body>
<%
List<BookInfo> bookInfos = (List<BookInfo>)request.getAttribute("bookInfos");
if(bookInfos==null){
bookInfos=new ArrayList<BookInfo>();
}
%>
<table>
<caption>新增图书类别列表</caption>
<tr>
<td>图书名称:</td>
<td><input name="bookName" size="40"></td>
</tr>
<tr>
<td>图书类别编号下拉框:</td>
<td>
<select name="course">
<%
for(BookInfo bookInfo : bookInfos){%>
<option value=<%=bookType.getBookTypeId()%>><%=bookType.getBookTypeId()%></option> <% }
%></select>
</td>
<tr>
<td><input type="submit" name="submit" value="保存"></td>
</tr>
</table>
</form>
</body>
</html>
下拉框的值是取另一个表的数据
我这样写填写信息后保存就弹错了
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Integer.java:415)
java.lang.Integer.parseInt(Integer.java:497)
com.wangwang.servlet.bookInfo.SaveBookInfoServlet.doPost(SaveBookInfoServlet.java:40)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.26 logs.
这个是图 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询