博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
web01-helloworld
阅读量:4627 次
发布时间:2019-06-09

本文共 720 字,大约阅读时间需要 2 分钟。

新建一个Java web项目,名字为web01

在项目中新建一个servlet,名字为SimpleHello

修改doGet()方法,为:

public void doGet(HttpServletRequest req, HttpServletResponse resp)            throws ServletException, IOException {        //得到PrintWriter对象        PrintWriter out=resp.getWriter();                //向客户端发送字符数据        out.println("hello world");        out.close();    }

配置web.xml为

<servlet>

<servlet-name>helloworld</servlet-name>
<servlet-class>SimpleHello</servlet-class>
</servlet>

<servlet-mapping>

<servlet-name>helloworld</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>

部署

浏览器中输入:localhost:8080/web01/hello

来访问刚才的servlet

结果截图:

-------------------------------------------

转载于:https://www.cnblogs.com/zhaixing/p/5680569.html

你可能感兴趣的文章
taro编译的时候报 exports.pRimraf = util_1.promisify(rimraf); 错误
查看>>
finalize()及垃圾回收
查看>>
MATLAB解析PFM格式图像
查看>>
多注入
查看>>
(HDU/UVA)1032/100--The 3n + 1 problem(3n+1问题)
查看>>
Web接口测试-HttpClient
查看>>
Linux简单入门
查看>>
【Linux】Linux统计文件夹、文件数量的命令
查看>>
vscode git
查看>>
Python虚拟环境的配置
查看>>
【Sort】希尔排序
查看>>
机器人关节数学模型
查看>>
解决无法wifi上网的问题
查看>>
uvalive 5731 Qin Shi Huang’s National Road System
查看>>
SULLEY安装与使用
查看>>
洛谷 1144 最短路计数 bfs
查看>>
C++ 单例模式
查看>>
C++ 我想这样用(四)
查看>>
T-2-java面向对象
查看>>
URL重定向及跳转漏洞
查看>>