⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updatesongaction.java

📁 本代码是点歌系统的部分代码实现了部分功能
💻 JAVA
字号:
package music.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import music.hibernate.Song;
import music.hibernate.SongType;
import music.service.SongService;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

public class UpdateSongAction extends DispatchAction {

	/**
	 *  
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 */
	public ActionForward edit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String ID = new String(request.getParameter("ID"));
		String name = request.getParameter("songName");
		if(name == null || name.trim().length() <= 0){
			SongService service = new SongService();
			Song m = service.getOneSong(ID);
			request.setAttribute("song", m);

			
			return mapping.findForward("edit");			
		}
		String typeID = new String(request.getParameter("typeID"));
		
		
	    SongType type = new  SongType();
		type.setSongTypeID(typeID);
		System.out.println("type is ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ " + typeID);		
			
		SongService service = new SongService();
		Song song = service.getOneSong(ID);
		song.setSongName(name);
		song.setSongtype(type);
		song.setSongID(typeID);
		service.updateSong(song);
		
		request.setAttribute("song", song);
		ActionForward af = new ActionForward();
		af.setPath("addSong.do?action=listSong");
		af.setRedirect(true);
		System.out.println("success----------------------- ");
		return af;
		
	}	
	public ActionForward delMusic(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {

		String ID = new String(request.getParameter("ID"));
			
		SongService service = new SongService();
		Song s = service.getOneSong(ID);
		service.delSong(s);
		
		request.setAttribute("song", s);
		ActionForward af = new ActionForward();
		af.setPath("addSong.do?action=listSong");
		af.setRedirect(true);
		return af;
		
	}
	
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -