码迷,mamicode.com
首页 > 数据库 > 详细

xml跟sql查找

时间:2017-09-21 11:17:33      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:下拉   ted   format   属性   images   ica   htm   path   load   

xml小白笔记 。。。。。。。

 

 <sql id="wDishesColumns"> 
        a.id AS "id",
        a.pid AS "pid",
        a.name AS "name",
        a.photo AS "photo",
        a.price AS "price",
        a.classification AS "classification",
        a.create_by AS "createBy.id",
        a.create_date AS "createDate",
        a.update_by AS "updateBy.id",
        a.update_date AS "updateDate",
        a.remarks AS "remarks",
        a.del_flag AS "delFlag",
        b.name AS "wFoodClassification.name"
    </sql>  
    
    
   <sql id="wDishesJoins">
    LEFT JOIN w_food_classification b ON b.id=a.pid 
    </sql>

 

left join 关联查询  关联字段  需要查找什么就在sql里面列出来 在获取

xml 跟dao 跟service 跟entity 跟controller 一个方法对应一个方法

 

 

<div class="control-group">
            <label class="control-label">照片:</label>
            <div class="controls">
                <!--<form:input path="photo" htmlEscape="false" maxlength="64" class="input-xlarge "/>-->
                <form:hidden id="nameImage" path="photo" htmlEscape="false" maxlength="255" class="input-xlarge"/>
                <sys:ckfinder input="nameImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
            </div>
        </div>

从服务器里添加照片代码

  

  <c:forEach items="${page.list}" var="wDishes">
            <tr>
                <td><a href="${ctx}/dis/wDishes/form?id=${wDishes.id}">
                    ${wDishes.name}
                </a></td>
                <td>
                    <img src="${wDishes.photo}" height="100" width="100"/> 
                </td>
                <td>
                    ${wDishes.price}
                </td>
                <td>
                     ${wDishes.wFoodClassification.name} 
                    
                </td>
                <td>
                    <fmt:formatDate value="${wDishes.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
                </td>
                <td>
                    ${wDishes.remarks}
                </td>
                <shiro:hasPermission name="dis:wDishes:edit"><td>
                    <a href="${ctx}/dis/wDishes/form?id=${wDishes.id}">修改</a>
                    <a href="${ctx}/dis/wDishes/delete?id=${wDishes.id}" onclick="return confirmx(‘确认要删除该菜名吗?‘, this.href)">删除</a>
                </td></shiro:hasPermission>
            </tr>
        </c:forEach>

 foreach 里面显示的属性 可以自己修改需要什么取出来

<div class="control-group">
            <label class="control-label">分类:</label>
            <div class="controls">
              <form:select path="wFoodClassification.id" class="input-xxlarge">
                     <form:options items="${find}"  itemLabel="name" itemValue="id" htmlEscape="false"/>                 
             </form:select>
            </div>
        </div>

获取items  用下拉框格式显示出来

 

 

 <form:form id="searchForm" modelAttribute="wDishes" action="${ctx}/dis/wDishes/" method="post" class="breadcrumb form-search">
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
          <ul class="ul-form">
            <li><label>名字:</label>
                <form:input path="name" htmlEscape="false" maxlength="10" class="input-medium"/>
            </li>
            <li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
            <li class="clearfix"></li>
        </ul>  
    </form:form>

jeesite自动生成的查询有错误的话  是controller方法里面没有取出来

在controller里面model取出来就好了

@RequiresPermissions("dis:wDishes:view")
    @RequestMapping(value = {"list", ""})
    public String list(WDishes wDishes, HttpServletRequest request, HttpServletResponse response, Model model) {
        Page<WDishes> page = wDishesService.findPage(new Page<WDishes>(request, response), wDishes); 
        model.addAttribute("page", page);
        model.addAttribute("wDishes", new WDishes());
        return "modules/dis/wDishesList";
    }

xml跟sql查找

标签:下拉   ted   format   属性   images   ica   htm   path   load   

原文地址:http://www.cnblogs.com/yelixin/p/7567343.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!