zoukankan      html  css  js  c++  java
  • {新人笔记 勿看} spring mvc第一步

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xsi:schemaLocation="http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
                http://www.springframework.org/schema/context
                http://www.springframework.org/schema/context/spring-context-4.0.xsd
                http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans.xsd">
        <mvc:annotation-driven/>
        <context:component-scan base-package="top.aiprogram.**"/>
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/view/"/>
            <property name="suffix" value=".jsp"/>
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        </bean>
    </beans>
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
             version="3.1">
        <servlet>
            <servlet-name>ssm-demo</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:./top/aiprogram/resource/spring-mvc.xml</param-value>
        </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>ssm-demo</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
    </web-app>
    package top.aiprogram.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    /**
     * Created by zekai on 2017/6/7.
     */
    @Controller
    @RequestMapping("user")
    public class UserController {
        @RequestMapping("/test")
        public String testUser(){
            return "user";
        }
        @RequestMapping("/demo")
        public String demoUser(){
            return "user";
        }
    }
    package top.aiprogram.user;
    
    /**
     * Created by zekai on 2017/6/7.
     */
    public class User {
        private int id;
        private String name;
    
        public int getId() {
            return id;
        }
    
        public void setId(int id) {
            this.id = id;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    }
  • 相关阅读:
    题解:SPOJ1026 Favorite Dice
    机器学习笔记
    机器学习第二次作业
    机器学习第一次作业
    2019软工实践总结作业
    软工2019作业6——软件评测
    2019软工作业五-实现师门树
    软件工程 “校园汇” 个人IDEA竞选分析与总结
    软工2019作业四
    软工2019作业三
  • 原文地址:https://www.cnblogs.com/tangzekai/p/6958247.html
Copyright © 2011-2022 走看看