<!-- <servlet>-->
<!-- <servlet-name>s</servlet-name>-->
<!-- <servlet-class>com.song.sevrlet1.test1</servlet-class>-->
<!-- </servlet>-->
<!-- <servlet-mapping>-->
<!-- <servlet-name>s</servlet-name>-->
<!-- <url-pattern>/myservlet</url-pattern>-->
<!-- </servlet-mapping>-->
package com.song.sevrlet1;
import javax.jws.WebService;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
@WebServlet("/demo1")
public class test1 implements Servlet {
@Override
public void init(ServletConfig servletConfig) throws ServletException {
}
@Override
public ServletConfig getServletConfig() {
return null;
}
@Override
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
System.out.println("开始执行了");
//乱码问题解决 相应之前调用方法
servletResponse.setContentType("text/html;charset=UTF-8");
String id = servletRequest.getParameter("id");
System.out.println("为" + id);
servletResponse.getWriter().write("hello");
servletResponse.getWriter().write("你好");
}
@Override
public String getServletInfo() {
return null;
}
@Override
public void destroy() {
}
}