您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
@WebServlet(name = "httpServletDemo",
urlPatterns = "/httpServletDemo",
initParams = {
@WebInitParam(name = "name", value = "username"),
@WebInitParam(name = "mobile", value = "1232423434")
})
@Controller
public class HttpServletDemo extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String name = getInitParameter("name");
String mobile = getInitParameter("mobile");
System.out.println("name:"+name+"; mobile:"+mobile);
resp.getWriter().print("this is a demo");
resp.setStatus(200);
}
@Override
protected long getLastModified(HttpServletRequest req) {
return super.getLastModified(req);
}
@Override
protected void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doHead(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doPost(req, resp);
}
@Override
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doPut(req, resp);
}
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doDelete(req, resp);
}
@Override
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doOptions(req, resp);
}
@Override
protected void doTrace(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.doTrace(req, resp);
}
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
super.service(req, resp);
}
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
String name = getInitParameter("name");
String mobile = getInitParameter("mobile");
System.out.println("name:"+name+"; mobile:"+mobile);
super.service(req, res);
}
}
spring boot 启动类
@SpringBootApplication
@EnableEurekaClient
@ServletComponentScan(basePackages = {"com.example.demo.filter","com.example.demo.interceptor","com.example.demo.servlet"})
public class SpringWebDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringWebDemoApplication.class, args);
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。