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;
        }
    }
  • 相关阅读:
    Web开发人员需知的Web缓存知识
    SQLServer常见性能问题
    C#面试常见题
    SQL Server数据库大型应用解决方案总结
    asp.net 缓存
    asp.net 的页面几种传值方式
    C# 连接SQL数据库以及操作数据库
    变量命名规则
    C# 委托
    删除文件
  • 原文地址:https://www.cnblogs.com/tangzekai/p/6958247.html
Copyright © 2011-2022 走看看