首页 > 编程知识 正文

servlet获取请求参数,servlet有什么用

时间:2023-05-03 22:33:00 阅读:48959 作者:4985

另一方面,在src下创建资源文件itcast.properties

Company=itcastAddress=Beijing,创建servlet并基于相对路径创建资源文件public class testservlet 06 extends http servlet { privatestaticfflet 相对路径* /公共void文档(httpservletrequestrequest,http servlet响应) throws ServletException,io exception printion //获取相对路径中的输入流对象。 第一个“/”表示web APP应用程序的根目录,而//完整路径表示文件相对于web APP应用程序的路径。 //src下的资源文件将在tomcat启动时复制到项目WEB-INF/classes目录下的inputstreamin=context .中,Properties pros=new Properties PROS.load(in ); out.println (' company=' pros.getproperty ) ' company ) ' br /' ); out.println (地址=) pros.getproperty ) (地址) (br /); 6三、启动Tomcat http://localhost :8080/chapter 03/testservlet 06

四.按绝对路径发布资源文件公共语音文档(httpservletrequestrequest,http servlet响应) throws ServletException,io exceppeption //文件的绝对路径string path=context.get realpath (/we B- INF/classes/itcast.properties ) ); fileinputstreamin=new file inputstream (path; Properties pros=new Properties (; PROS.load(in ); out.println(path; out.println (' company=' pros.getproperty ) ' company ) ' br ' ); out.println (地址=) pros.getproperty ) (地址) (br ); }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。