当前位置:   article > 正文

MyEclipse web 简单 网站项目 创建_myeclipse可以制作网站吗

myeclipse可以制作网站吗

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-v7T4HjXh-1664173167415)(//img-blog.csdn.net/20180321111039363?watermark/2/text/Ly9ibG9nLmNzZG4ubmV0L3gxNDc5NDUyOTk0/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)]
web网站后台程序 简单使用

package edu.servlets.test;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.*;

public class test extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String name = req.getParameter("user");
		name = new String(name.getBytes("ISO-8859-1"),"UTF-8");
		System.out.println("get 请求!");
		System.out.println("名字:"+name);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		String name = req.getParameter("user");
	System.out.println("post请求!");
	//响应式客户端
	//设置响应类型 text/html 网页  charset
	resp.setContentType("text/html;charset=utf-8");
	//获得字符输出的对象
	PrintWriter out = resp.getWriter();
	//输出网页内容
	out.println("<DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EM\">");
	out.println("<HTML>");
	out.println("<HEAD><TITLE>测试响应</TITLE><meta http-equiv='content-type' content='text/html;charset=UTF-8'></HEAD>");
	out.println("<BODY>");
	out.println("<h1>欢迎老傻逼回家!"+name+"<h1>");
	out.println("</BODY>");
	out.println("</HTML>");
	out.flush();
	out.close();
	System.out.println("POST的数据:"+name);
	
	}

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

客服端简单 处理

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>index.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

  </head>
  
  <body >
    <form method="post" action="test">
    <input type="text" name="user"><br>
    <input type="submit" value="提交">
    </form>
  </body>
</html>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

**xml网站简单配置 servlet 简单配置路径 **

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	<servlet>
			<servlet-name>test</servlet-name>
			<servlet-class>edu.servlets.test.test</servlet-class>
	</servlet>
	
	<!-- 映射路径 -->
	<servlet-mapping>
			<servlet-name>test</servlet-name>
			<url-pattern>/test</url-pattern>
	</servlet-mapping>
	
	  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
</web-app>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/175165
推荐阅读
相关标签
  

闽ICP备14008679号