1. 目录结构
  2. AppInitializer.java
    1. package com.jt;
      
      import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
      
      public class AppInitializer   extends AbstractAnnotationConfigDispatcherServletInitializer{
      @Override
      protected Class<?>[] getRootConfigClasses() {
      return new Class<?>[] { RootConfig.class };
      } @Override
      protected Class<?>[] getServletConfigClasses() {
      return new Class<?>[] { WebConfig.class };
      } @Override
      protected String[] getServletMappings() {
      return new String[] { "/" };
      } }
  3. RootConfig.java
    1. package com.jt;
      
      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.ComponentScan.Filter;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.web.servlet.config.annotation.EnableWebMvc; @Configuration
      public class RootConfig { }
  4. WebConfig.java
    1. package com.jt;
      
      import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.web.servlet.ViewResolver;
      import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
      import org.springframework.web.servlet.config.annotation.EnableWebMvc;
      import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
      import org.springframework.web.servlet.view.InternalResourceViewResolver; @Configuration
      @EnableWebMvc
      @ComponentScan("com.jt")
      public class WebConfig extends WebMvcConfigurerAdapter {
      public WebConfig(){
      System.out.println("WebConfig");
      }
      @Bean
      public ViewResolver viewResolver() {
      InternalResourceViewResolver resolver = new InternalResourceViewResolver();
      resolver.setPrefix("/WEB-INF/views/");
      resolver.setSuffix(".jsp");
      resolver.setExposeContextBeansAsAttributes(true);
      return resolver;
      } @Override
      public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
      configurer.enable();
      }
      }
  5. HelloControl.java
    1. package com.jt;
      
      import java.sql.Date;
      import java.util.Map; import javax.validation.Valid; import org.springframework.stereotype.Component;
      import org.springframework.stereotype.Controller;
      import org.springframework.ui.Model;
      import org.springframework.validation.BindingResult;
      import org.springframework.validation.Errors;
      import org.springframework.validation.ObjectError;
      import org.springframework.web.bind.annotation.PathVariable;
      import org.springframework.web.bind.annotation.RequestMapping;
      import org.springframework.web.bind.annotation.RequestMethod;
      import org.springframework.web.bind.annotation.RequestParam;
      import org.springframework.web.bind.annotation.RequestMethod.*; import com.myOrg.DeptUserDomain; @Controller
      @RequestMapping(value = "/FirstControl")
      public class HelloControl {
      @RequestMapping(value="/registerDeptUser",method=RequestMethod.GET)
      public String register(){ return "registerDeptUser";
      }
      }
  6. registerDeptUser.jsp
    1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>Insert title here</title>
      </head>
      <body>
      <form method="post">
      id:<input type="text" name="id" /><br /> name:<input type="text"
      name="name" /><br /> <input type="submit" value="submit" />
      </form>
      </body>
      </html>
  7. 运行
  8. 参考:https://blog.csdn.net/bufanqi_info/article/details/78922534

最新文章

  1. log4net 记录日志到sqlserver
  2. 02 Apache Solr: 概览 Solr在信息系统架构中的位置
  3. Docker - Docker国内镜像的配置及使用
  4. zTree的使用2
  5. Linux下查看文件内容的命令
  6. 【C#】【Thread】Monitor和Lock
  7. 【原创】Quartz代码详解
  8. spoj 2319 BIGSEQ - Sequence
  9. Js打开新窗口拦截问题整理
  10. 201521123031 《Java程序设计》第13周学习总结
  11. [lua][openresty]代码覆盖率检测的解决方式
  12. 微信小程序picker的坑
  13. Django 序列化-token
  14. 使用 jquery.wordexport.js导出的Word排版
  15. 【javascript小案例】从0开始实现一个俄罗斯方块
  16. io系列之其他类
  17. SAP CRM 忠诚度相关表的关系图
  18. Unable to cast COM object of type &#39;Shell32.ShellClass&#39; to interface type &#39;Shell32.IShellDispatch6&#39;.
  19. Vue2.5开发去哪儿网App 首页开发
  20. python-day47--mysql数据备份与恢复

热门文章

  1. JavaScript 数据结构与算法之美 - 冒泡排序、插入排序、选择排序
  2. 老司机也晕车--java字符串String晕车之旅
  3. Python和Sublime安装教程
  4. B-generator 1_2019牛客暑期多校训练营(第五场)
  5. hdu 5903 Square Distance(dp)
  6. mysql 主主从配置
  7. jstat虚拟机统计信息监视工具
  8. (六十七)c#Winform自定义控件-柱状图
  9. CNCF 宣布成立应用交付领域小组,正式开启云原生应用时代
  10. ORACLE SQL语句练习题