phone-list-add下拉框

package com.dengyingjie.service;

import java.util.List;

import com.dengyingjie.pojo.Phone;
import com.dengyingjie.pojo.Software;
import com.github.pagehelper.PageInfo;

public interface PhoneService {

PageInfo list(int page,Phone phone);

List getSlist();

void add(Phone phone);

}

package com.dengyingjie.dao;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.dengyingjie.pojo.Phone;
import com.dengyingjie.pojo.Software;

public interface PhoneDao {

List list(Phone phone);

@Select("select * from software")
List getSlist();

void addPhone(Phone phone);

void addMiddle(Phone phone);

}

package com.dengyingjie.service.impl;

import java.util.List;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import com.dengyingjie.dao.PhoneDao;
import com.dengyingjie.pojo.Phone;
import com.dengyingjie.pojo.Software;
import com.dengyingjie.service.PhoneService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@Service
public class PhoneServiceimpl implements PhoneService {

@Autowired
PhoneDao phonedao;

@Override
public PageInfo list(int page,Phone phone) {
	PageHelper.startPage(page,4);
	return new PageInfo(phonedao.list(phone));
}

@Override
public void add(Phone phone) {
	phonedao.addPhone(phone);
	phonedao.addMiddle(phone);
}

@Override
public List getSlist() {
	return phonedao.getSlist();
}

}

select a.*,group_concat(c.sname) name from phone a left join middle b on a.pid=b.pid left join software c on b.sid=c.sid a.pname like '%${pname}%' GROUP BY a.pid insert into phone values(null,#{pname},#{dec},#{price}) insert into middle (pid,sid) values (#{pid},#{software.sid})

package com.dengyingjie.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.dengyingjie.pojo.Phone;
import com.dengyingjie.pojo.Software;
import com.dengyingjie.service.PhoneService;
import com.github.pagehelper.PageInfo;

@Controller
public class PhoneController {

@Reference
PhoneService phoneService;

@RequestMapping("list")
public String list(HttpServletRequest request,@RequestParam(defaultValue="1")int page,Phone phone) {
	PageInfo list=phoneService.list(page, phone);
	request.setAttribute("pageInfo", list);
	return "list";
}

@RequestMapping("/toAdd")
public String toAdd(Phone phone,Model model) {
	List list=phoneService.getSlist();
	model.addAttribute("p",phone);
	model.addAttribute("l",list);
	return "add";
}

@RequestMapping("/add")
public String add(Phone phone,Model model) {
	List softwares=phone.getSoftwares();
	phoneService.add(phone);
	return "redirect:list";
}

}

<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c” %>

Insert title here 手机名称: 、 、 、 <、button name="page" value="1">首页 <、button name="page" value="${pageInfo.prePage==0?1:pageInfo.prePage}">上一页 <、button name="page" value="${pageInfo.nextPage==0?pageInfo.pages:pageInfo.nextPage}">下一页 、 <、button name="page" value="${pageInfo.pages }">尾页 、 、
序号 手机名称 手机描述 手机价格 安装的软件
${l.pid } ${l.pname } ${l.dec } ${l.price } ${l.name }

<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c” %>
<%@ taglib uri=“http://www.springframework.org/tags/form” prefix=“form” %>

Insert title here 手机名称:
手机描述:
手机价格:
安装的软件: ${l.sname }

你可能感兴趣的:(phone-list-add下拉框)