📄 updatechargeservlet.java
字号:
package unicom.action;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import unicom.factory.ServiceFactory;
import unicom.service.IChargeService;
/**
* @author xiaogang
* 日期:Apr 18, 2008
* 功能:修改页面表单信息,从客户端取出收费项目和金额,保存到数据库中
* 优点:
* 缺点:
* 建议:
*/
public class UpdateChargeServlet extends HttpServlet {
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//防止中文乱码
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
//从客户端取得code和charge值
String code = request.getParameter("code");
String charge = request.getParameter("charge");
//得到客户端输出流
PrintWriter out = response.getWriter();
//用简单工厂生成IChargeService对象
IChargeService chargeService = ServiceFactory.createChargeService();
if(chargeService.updateCharge(code, Double.parseDouble(charge)))
out.println("修改成功");
else
out.println("修改失败");
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -