java web开发,表单提交,
我已经建立blog类和Category类,,两个的.hbm.xml都映射好了category和blog是一对多的关系在hbm.xml中已经做好映射publicclassB...
我已经建立blog类 和Category类,, 两个的.hbm.xml都映射好了 category和blog是一对多的关系 在hbm.xml中已经做好映射
public class Blog {
private int id;
private Category category;
private String title;
private String content;
private Date createdTime;
private Integer id;
private String name;
private String level;
<form id="form1" name="form1" method="post" action="addBlog">
<table id="tab">
<tr>
<td>
主题:
</td>
<td>
<input name="title" type="text" id="title" size="100" />
</td>
</tr>
<tr>
<td>
分类:
</td>
<td>
<select name="categoryId" id="select" >
<%
List<Category> list = (List<Category>) request.getAttribute("list");
for (int i = 0; i < list.size(); i++) {
Category c = (Category) list.get(i);
%>
<option value="<%=c.getId()%>"><%=c.getName()%></option>
<%
}
%>
</select>
<!--
<s:select name="categoryId" list="#request.list" listKey="id"
listValue="name">
</s:select>
-->
</td>
</tr>
<tr>
<td colspan="2">
内容:
<br />
<textarea name="content" cols="100" rows="18" id="content"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submit" value="创建" />
</td>
</tr>
</table>
</form>
如何插入blog数据
<select name="categoryId" id="select" >
<%
List<Category> list = (List<Category>) request.getAttribute("list");
for (int i = 0; i < list.size(); i++) {
Category c = (Category) list.get(i);
%>
<option value="<%=c.getId()%>"><%=c.getName()%></option>
<%
}
%>
</select>
主要是这个 下拉框 我想传入,,category对象 ,,但是 不知道怎么传 无法接收到数据 展开
public class Blog {
private int id;
private Category category;
private String title;
private String content;
private Date createdTime;
private Integer id;
private String name;
private String level;
<form id="form1" name="form1" method="post" action="addBlog">
<table id="tab">
<tr>
<td>
主题:
</td>
<td>
<input name="title" type="text" id="title" size="100" />
</td>
</tr>
<tr>
<td>
分类:
</td>
<td>
<select name="categoryId" id="select" >
<%
List<Category> list = (List<Category>) request.getAttribute("list");
for (int i = 0; i < list.size(); i++) {
Category c = (Category) list.get(i);
%>
<option value="<%=c.getId()%>"><%=c.getName()%></option>
<%
}
%>
</select>
<!--
<s:select name="categoryId" list="#request.list" listKey="id"
listValue="name">
</s:select>
-->
</td>
</tr>
<tr>
<td colspan="2">
内容:
<br />
<textarea name="content" cols="100" rows="18" id="content"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submit" value="创建" />
</td>
</tr>
</table>
</form>
如何插入blog数据
<select name="categoryId" id="select" >
<%
List<Category> list = (List<Category>) request.getAttribute("list");
for (int i = 0; i < list.size(); i++) {
Category c = (Category) list.get(i);
%>
<option value="<%=c.getId()%>"><%=c.getName()%></option>
<%
}
%>
</select>
主要是这个 下拉框 我想传入,,category对象 ,,但是 不知道怎么传 无法接收到数据 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询