jsp中引用Dao或Service

    xiaoxiao2021-03-25  71

    <%@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>
    转载请注明原文地址: https://ju.6miu.com/read-33351.html

    最新回复(0)