public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
Songs song = (Songs)request.getAttribute("song");
ShowAllSongs sas = new ShowAllSongs();
PrintWriter out = response.getWriter();
int result = sas.updataSonginfo(song, song.getSongid());
if(result == 0){
out.println("更新失败!请重新检查或联系开发者!</p>");
out.println("<a href=\"./showAllSongList.jsp\" >返回歌曲列表</a>");
}else{
out.println("更新成功!</p>");
out.println("<a href=\"./showAllSongList.jsp\" >返回歌曲列表</a>");
}
}
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.fjzkx.onlineTelQQ.biz.ShowAllSongs"/>
<jsp:directive.page import="com.fjzkx.onlineTelQQ.data.Songs"/>
<jsp:directive.page import="com.fjzkx.onlineTelQQ.db.DBConnection"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'editSongsInfo.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="编辑歌曲信息">  </head>
  
  <body>
   <%
   Songs song = new Songs();
   String sid = request.getParameter("songid");
   int songid = Integer.parseInt(sid);
   ShowAllSongs showAllSongs = new ShowAllSongs();
   try{
   song = showAllSongs.getSongInfo(songid);
   }catch(Exception e){
   e.printStackTrace();
   }
   if(song!=null){
    %>
   <form action="/www/servelet/editSongInfo" method="post">
<table border="1" align="center">
     <tr>
         <th align="center">歌曲编号</th>
     <th align="center">分类编号</th>
     <th align="center">拼音字母</th>
     <th align="center">歌曲地址</th>
     <th align="center">加入时间</th>
     <th align="center">歌曲名称</th>
     <th align="center">歌手</th>
     <th align="center">图片地址</th>
     <th align="center">大图片地址</th>
     <th align="center">小图片地址</th>
     <th align="center">歌词地址</th>
     <th align="center">频道</th>
     <th align="center">点击率</th>
     <th align="center">备注</th>
     </tr>
     <tr>
     <td><input id="songid" name="songid" type="text" value="<%=song.getSongid()%>"/></td>
     <td><input id="typeid" name="typeid" type="text" value="<%=song.getTypeid()%>"/></td>
     <td><input id="abc" name="abc" type="text" value="<%=song.getAbc()%>"/></td>
     <td><input id="songurl" name="songurl" type="text" value="<%=song.getSongurl()%>"/></td>
     <td><input id="dateandtime" name="dateandtime" type="text" value="<%=song.getDateandtime()%>"/></td>
     <td><input id="title" name="title" type="text" value="<%=song.getTitle()%>"/></td>
     <td><input id="singer" name="singer" type="text" value="<%=song.getSinger()%>"/></td>
     <td><input id="img" name="img" type="text" value="<%=song.getImg()%>"/></td>
     <td><input id="imgb" name="imgb" type="text" value="<%=song.getImgb()%>"/></td>
     <td><input id="imgs" name="imgs" type="text" value="<%=song.getImgs()%>"/></td>
     <td><input id="lrc" name="lrc" type="text" value="<%=song.getLrc()%>"/></td>
     <td><input id="channel" name="channel" type="text" value="<%=song.getChannel()%>"/></td>
     <td><input id="hits" name="hits" type="text" value="<%=song.getHits()%>"/></td>
     <td><input id="demo" name="demo" type="text" value="<%=song.getDemo()%>"/></td>
     </tr>
     <tr>
     <td colspan="14" align="center"><input type="submit" value="提交修改"/></td>
     </tr>
   <%
   Songs sgs = new Songs();
   int txttypeid = 0;
   int txthits = 0;
   String txtsongid = request.getParameter("songid");
   String testtypeid = request.getParameter("typeid");
   if(testtypeid!=null){
   txttypeid = Integer.parseInt(testtypeid);
   }
   String txtabc = request.getParameter("abc");
   String txtsongurl = request.getParameter("songurl");
   String txtdateandtime = request.getParameter("dateandtime");
   String txttitle = request.getParameter("title");
   String txtsinger = request.getParameter("singer");
   String txtimg = request.getParameter("img");
   String txtimgb = request.getParameter("imgb");
   String txtimgs = request.getParameter("imgs");
   String txtlrc = request.getParameter("lrc");
   String txtchannel = request.getParameter("channel");
   String testhits = request.getParameter("hits");
   if(testhits!=null){
   txthits = Integer.parseInt(testhits);
   }
   String txtdemo = request.getParameter("demo");
   sgs.setTypeid(txttypeid);
   sgs.setAbc(txtabc);
   sgs.setSongurl(txtsongurl);
   sgs.setDateandtime(txtdateandtime);
   sgs.setTitle(txttitle);
   sgs.setSinger(txtsinger);
   sgs.setImg(txtimg);
   sgs.setImgb(txtimgb);
   sgs.setImgs(txtimgs);
   sgs.setLrc(txtlrc);
   sgs.setChannel(txtchannel);
   sgs.setHits(txthits);
   sgs.setDemo(txtdemo);
   request.setAttribute("song", sgs);
   }else{
    %>
     <h2 align="center">对不起,系统错误,或没有相应的信息,请检查或联系开发者!</h2>
    <%
     }
     %>
  </form>
  </body>
</html>