JavaWeb-1 动态网页开发

1.新建动态网页项目

 2.新建Selvert类 

 

 生成.java文件

 打开AxHelloJavaWeb.java文件,查看doGet和doPost方法,测试运行。

修改doGet代码如下:

1     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
2         // TODO Auto-generated method stub
3         response.getWriter().append("Served at: ").append(request.getContextPath()).append("\n");
4         String jsonString="Hello JavaWeb";    
5         response.setContentType("application/json");
6         PrintWriter out = response.getWriter();
7         out.append(jsonString);
8 
9     }

运行代码效果如下:

 

posted @ 2024-12-16 09:50  太一吾鱼水  阅读(6)  评论(0编辑  收藏  举报