servlet读取web.xml中参数和页面转向方法
来源:互联网 发布:mac中safari下载视频 编辑:程序博客网 时间:2024/05/01 01:37
servlet读取web.xml中参数和页面转向方法
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Loginv1Servlet extends HttpServlet {
private String xmlName,xmlPass;
protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {
doPost(arg0, arg1);
}
public void init(ServletConfig config) throws ServletException {
// 初始化时候对xml文档的内容进行读取 //这个是重写超类方法
xmlName=config.getInitParameter("name");
xmlPass=config.getInitParameter("pass");
/*
* <init-param>
* <param-name>pass</param-name>
* <param-value>123456</param-value>
*xml文件中的写法,写在<servlet> 块内
* </init-param>
*/
}
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
//首先对客户端的数据流编码 解决中文问题
req.setCharacterEncoding("GB2312");
// 得到客户传递的数据
String str= req.getParameter("action");
String id=req.getParameter("id");
String name=req.getParameter("name");
String amount=req.getParameter("amount");
res.setContentType("text/html;charset=gb2312");
PrintWriter pw=res.getWriter();
pw.println("<html>");
pw.println("<title>准备购买的商品信息</title><body>");
pw.println("编号:"+ id);
pw.println("名称:"+ name);
pw.println("数量:"+ amount);
if("1".equals(str)){
//电子支付
pw.println("<a href='http://www.post.com.cn'target=_blank> 进入网上银行</a>");
}else{
//汇款
pw.println("<a href='info.html'>填写详细信息</a>");
}
pw.println("</body>");
pw.println("</html>");
}
}
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1798509
- servlet读取web.xml中参数和页面转向方法
- 读取Web.xml中各种参数的方法
- Servlet获取web.xml中的参数方法
- 读取web.xml中各种类型参数的方法(读取资源文件)
- Servlet(19)web.xml 配置之Servlet参数配置和读取资源文件,获取文件全路径
- 读取web.xml参数
- 读取web.xml参数
- java Web.xml中servlet配置方法
- Servlet 中 web.xml 中的 servlet 和 servlet-mapping 标签
- web.xml中在Servlet中获取context-param和init-param内的参数
- 解析web.xml中在Servlet中获取context-param和init-param内的参数
- web.xml中在Servlet中获取context-param和init-param内的参数
- web.xml中在Servlet中获取context-param和init-param内的参数
- web.xml中在Servlet中获取context-param和init-param内的参数
- web.xml中在Servlet中获取context-param和init-param内的参数
- web.xml中在Servlet中获取context-param和init-param内的参数
- 在Servlet和JSP中访问web.xml设置的初始参数
- servlet中配置文件web.xml中的参数context-param和init-param
- 中秋随笔-在中秋之际,祝所有Coder,特别是身在他乡的Coder节日快乐!
- 犹太人经商25法则
- Statement (2)
- Windows API一日一练(44)wsprintf函数
- jsp语法之动作篇
- servlet读取web.xml中参数和页面转向方法
- 完成端口实现echo tcp server
- Apache conf中文说明
- How to Setup Apache With FastCGI And Ruby Bindings
- 中秋前夕
- 威金.绝望logo1_.exe 9sy.exe dll.dll rundl132.exe _desktop.ini
- 史上最完整的ruby,rails环境架设配置(Apache+fastcgi)
- 人生感悟
- 2007中秋节中/英文祝福短信