zoukankan      html  css  js  c++  java
  • spring mvc 注解示例

    springmvc.xml

    <?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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc
         http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-4.1.xsd">
        <!-- spring mvc 注解驱动 -->
        <mvc:annotation-driven />
        <!-- 扫描器 -->
        <context:component-scan base-package="com" />
    
        <!-- 配置视图 解析器 -->
        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <!-- 前缀和后缀 -->
            <property name="prefix" value="/view/"></property>
            <property name="suffix" value=".jsp"></property>
        </bean>
    </beans>

    handler

    package com.stone.controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    /**
     * user/list.do
     * user/add.do
     */
    @Controller
    @RequestMapping("/user")
    public class UserController {
    
        @RequestMapping(value = "/list.do")
        public String list() {
            System.out.println("---------查询用户信息----------");
            return "userinfo/user_list";
        }
    
        @RequestMapping("/add.do")
        public String add() {
            System.out.println("---------用户信息添加------------");
            return "userinfo/user_add";
        }
    
        @RequestMapping("/update.do")
        public String update() {
            System.out.println("---------用户信息修改------------");
            return "userinfo/user_update";
        }
    }

    jsp位于WebRoot/view/userinfo/user_*.jsp;

  • 相关阅读:
    Qt实战6.万能的无边框窗口(FramelessWindow)
    Qt实战5.如何获取USB设备信息?
    Qt实战4.简单封装的文件监控
    Qt实战3.Qt仿Win10风格界面
    Linux下使用脚本让程序顺序启动
    项目经验1.软件的开发过程
    Qt实战2.老生常谈的文件传输
    mysql导入txt文件
    linux离线安装python3
    mysql知识点
  • 原文地址:https://www.cnblogs.com/stono/p/4482412.html
Copyright © 2011-2022 走看看