?? changefilename.java
字號:
package servlet;
import java.io.IOException;
import java.sql.*;
import common.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.sun.java_cup.internal.internal_error;
/**
* @author 隋玉杰 E-mail: suiyj1158@hotmail.com
* @version 創建時間:Nov 21, 2008 12:59:58 AM
* 更改文件信息
*/
public class ChangeFileName extends HttpServlet {
public ChangeFileName() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("gbk");
String fileid = request.getParameter("fileid");
String typeid = request.getParameter("typeid");
String bumenid=request.getParameter("bumenid");
String newname = request.getParameter("filename").trim();
String newdescribe = request.getParameter("describe").trim();
String sqlString = null;
String oldpath = null;
String newpath = null;
String realpath = this.getServletContext().getRealPath("/");
int c_typeid = 0;
Connection conn = DAO.getConnection();
try {
Statement statement = conn.createStatement();
sqlString = "select c_name,c_typeid from t_file where c_id="
+ fileid;
ResultSet rSet = statement.executeQuery(sqlString);
if (rSet.next()) {
c_typeid = rSet.getInt(2);
oldpath = realpath + GetUrl.geturl(Integer.parseInt(typeid))
+ rSet.getString(1);
newpath = realpath + GetUrl.geturl(Integer.parseInt(typeid))
+ newname;
sqlString = "update t_file set c_name='" + newname
+ "',c_describe='" + newdescribe + "',c_departid= "+Integer.parseInt(bumenid)+" where c_id="
+ fileid;
statement.executeUpdate(sqlString);
}
rSet.close();
statement.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
FileOperate fo = new FileOperate();
fo.renameFolder(oldpath, newpath);
response.sendRedirect("model/admin/adminindex.jsp?typeid=" + c_typeid);
}
public void init() throws ServletException {
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -