jsp中引用Dao或Service

<%@page import="com.service.CategoryService"%>
<%@page import="com.po.Category"%>
<%@page import="org.springframework.context.support.ClassPathXmlApplicationContext"%>



<tr>
                        <td align="right">所屬類型:</td>
					    <td><select name="categoryId" >
                          <option selected="selected">==請選擇==</option>
                          <%
			          		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
			          		CategoryService categoryService = (CategoryService)ctx.getBean("categoryService");
			          		List<Category> cList = categoryService.getAllCategory();
			          		for(int i =0 ; i< cList.size();i++){
			          			Category c = cList.get(i);
			          	%>	
			          		<option value="<%=c.getCategoryId() %>" ><%=c.getCategoryname() %></option>
			          	<% 
			          		}
			          	 %>
                          
                        </select></td>
					    </tr>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章