spirng mvc
来源:互联网 发布:js根据id获取div 编辑:程序博客网 时间:2024/05/16 23:59
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> <a href="hello">Hello</a></body></html>
2.编写一个普通的类,POJO作为Controller
package com.spring.mvc;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;//pojo一个普通类 作为 控制器@Controllerpublic class Helloworld {/* * 映射一个叫hello的请求,同一个请求要唯一,@RequestMapping("/hello")不能出现两个 * 可以不同的请求转发到同一个页面*/@RequestMapping("/hello")public String hello(){System.out.println("fds");/* * 返回hello给DispatcherServlet作为前缀名转发*/return "hello";}}3.配置一个servlet来转发请求,spring中已经有一个核心类springDispatcherServlet来处理了
<!-- 配置DispatcherServlet --> <!-- The front controller of this Spring Web application, responsible for handling all application requests --><servlet><servlet-name>springDispatcherServlet</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><!--需要转发的请求来自spring.mvc.xml --><param-value>classpath:spring-mvc.xml</param-value></init-param><!-- web容器启动的时候加载配置 --><load-on-startup>1</load-on-startup></servlet><!-- Map all requests to the DispatcherServlet for handling --><servlet-mapping><servlet-name>springDispatcherServlet</servlet-name><!-- 拦截所有请求 --> <url-pattern>/</url-pattern></servlet-mapping>4.配置spring.mvc.ml
<!-- 自动扫描包 --> <context:component-scan base-package="com.spring.mvc"></context:component-scan> <!-- 视图解析器 --> <bean id="" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/"></property> <property name="suffix" value=".jsp"></property> </bean>
阅读全文
0 0
- spirng mvc
- Spirng MVC 入门教程
- spirng mvc配置文件
- Spirng MVC 入门教程--转发
- Spirng MVC拦截器的应用
- Spirng MVC中常用的注解
- 基于注解的Spirng MVC框架的搭建(基础篇)
- Velocity + log4j + Spring MVC + Spirng + MyBatis + Maven整合
- spirng Framework
- Spirng 学习心得
- spirng 乱码
- spirng配置
- Spring Web Flow 2简化页面流的开发,结合Spring MVC更俊,Spirng Security 3添加安全机制
- Spring Web Flow 2简化页面流的开发,结合Spring MVC更俊,Spirng Security 3添加安全机制
- Spring Web Flow 2简化页面流的开发,结合Spring MVC更俊,Spirng Security 3添加安全机制
- spirng+struts+hibernate实例
- 阐释Spirng(入门)
- Spirng管理bean示例
- 安装并配置ROS环境(一)
- 并发VS并行,你确定你懂了吗?
- 关于判断一个矩形能否容下两个圆
- 一个蛋疼的PIL图片读取问题
- RMAN-20039: 设置双工模式时格式中需要有 %c 解决办法
- spirng mvc
- css中position的absolute与relative的使用
- pythpn基础学习之——整数除法
- HTTP Session和Cookie工作原理
- C++ 结构体 共用体和枚举
- linux sort,uniq,cut,wc命令详解
- 编码字符集Unicode与编码方式UTF-8是个什么样的关系
- JavaScript对嵌套数组做扁平化处理
- Android音频系统之音频框架