package com.song.action; import java.io.IOException; import java.util.Iterator; import java.util.List; import javax.servlet.http.HttpServletResponse; import net.sf.json.JSONArray; import org.apache.struts2.ServletActionContext; import com.song.Entity.Singer; import com.song.Entity.Song; import com.song.service.SongService; import com.song.util.Page; public class SongAction { private SongService service; private List list; private String current; private Page page; private List locationlist; private List singerlist; private String lid; private String sid; private Song song; private int id; //----------------------------------------------------------------------------------- //列表加分页 public String list(){ int count = service.getcount(); page = new Page(current, count, "3"); list = service.getlist(page); return "list"; } //跳转添加页面 public String toadd(){ return "add"; } //查询地区 public void location() throws IOException { locationlist = service.getlocationlist(); HttpServletResponse response = ServletActionContext.getResponse(); JSONArray json = JSONArray.fromObject(locationlist); response.getWriter().print(json.toString()); } //查询歌手 public void singer() throws IOException { singerlist = service.getsingerlist(); HttpServletResponse response = ServletActionContext.getResponse(); Iterator it = singerlist.iterator(); while(it.hasNext()){ Singer singer = (Singer) it.next(); singer.setLocation(null); } JSONArray json = JSONArray.fromObject(singerlist); response.getWriter().print(json.toString()); } //真添加 public void doadd() throws IOException{ HttpServletResponse response = ServletActionContext.getResponse(); System.out.println(sid); System.out.println(lid); int i = service.doadd(song,sid,lid); if(i>0){ response.getWriter().print(true); } } //修改页面 public String toupdate(){ song = service.getbyid(id); return "update"; } //回显基本信息 public void ajax() throws IOException{ JSONArray json = JSONArray.fromObject(song); HttpServletResponse response = ServletActionContext.getResponse(); response.getWriter().print(json.toString()); } //修改 public void doupdate() throws IOException{ int i = service.doupdate(song,sid,lid); HttpServletResponse response = ServletActionContext.getResponse(); if(i>0){ response.getWriter().print(true); } } //删除 public String doDel(){ song = service.doDel(id); return list(); } //----------------------------------------------------------------------------------- public SongService getService() { return service; } public void setService(SongService service) { this.service = service; } public List getList() { return list; } public void setList(List list) { this.list = list; } public String getCurrent() { return current; } public void setCurrent(String current) { this.current = current; } public Page getPage() { return page; } public void setPage(Page page) { this.page = page; } public List getLocationlist() { return locationlist; } public void setLocationlist(List locationlist) { this.locationlist = locationlist; } public List getSingerlist() { return singerlist; } public void setSingerlist(List singerlist) { this.singerlist = singerlist; } public String getLid() { return lid; } public void setLid(String lid) { this.lid = lid; } public String getSid() { return sid; } public void setSid(String sid) { this.sid = sid; } public Song getSong() { return song; } public void setSong(Song song) { this.song = song; } public int getId() { return id; } public void setId(int id) { this.id = id; } }
最近下载更多
lsglsg9 LV23
2021年11月24日
123456hdhdhdhd LV7
2020年8月20日
12345678fy LV1
2020年5月21日
i like you LV2
2020年4月26日
恣意ah LV7
2020年1月2日
wr463913813 LV5
2019年12月27日
zhengjin12 LV9
2019年12月19日
13148918399 LV9
2019年12月10日
渺无人烟 LV11
2019年11月6日
yuanchuang LV22
2019年10月8日