📄 tpublishservlet.java
字号:
package com.jblack.servlet;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.jblack.dao.TcompanyDAO;
import com.jblack.dao.TpublishDAO;
import com.jblack.model.Tcompany;
import com.jblack.model.Tpublish;
import com.jblack.tool.BaseServlet;
public class TpublishServlet extends BaseServlet {
private static final long serialVersionUID = -1054273217679696815L;
private TpublishDAO tpublishDAO = new TpublishDAO();
private TcompanyDAO tcompanyDAO = new TcompanyDAO();
private SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
public void doBusiness() {
Tpublish st = new Tpublish();
String tcusername = (String) request.getSession().getAttribute(
"username");
Tcompany tc = tcompanyDAO.getpub(tcusername);
String tpname = request.getParameter("tpname");
double tpinitPrice = Double.parseDouble(request
.getParameter("tpinitPrice"));
double tpmodPrice = Double.parseDouble(request
.getParameter("tpmodPrice"));
String tpdescription = request.getParameter("tpdescription");
Date tppubDate;
Date tpdeadline;
Date tpgameDate;
Date tpgameDeadline;
try {
tppubDate = date.parse(request.getParameter("tppubDate"));
tpdeadline = date.parse(request.getParameter("tpdeadline"));
tpgameDate = date.parse(request.getParameter("tpgameDate"));
tpgameDeadline = date.parse(request.getParameter("tpgameDeadline"));
st.setTcid(tc.getTcid());
st.setTpname(tpname);
st.setTpinitPrice(tpinitPrice);
st.setTpmodPrice(tpmodPrice);
st.setTpdescription(tpdescription);
st.setTppubDate(tppubDate);
st.setTpdeadline(tpdeadline);
st.setTpgameDate(tpgameDate);
st.setTpgameDeadline(tpgameDeadline);
st.setTpstatus(Tpublish.UNPASS);
System.out.println("do"+st.getTcid());
System.out.println(st.getTcid());
} catch (ParseException e) {
e.printStackTrace();
}
tpublishDAO.save(st); //不能放在异常中
List<Tpublish> tpublishs = tpublishDAO.queryAll();
request.setAttribute("tpublishs", tpublishs);
forward("/company/publish/th_tpublish.jsp");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -