springmvc 配置文件
来源:互联网 发布:淘宝网首页戴丝玉 编辑:程序博客网 时间:2024/05/16 12:08
1、在同级目录下。默认就ok
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>springMVC1</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>springMVC</servlet-name> <!-- 这个名字就是配置文件 springMVC-servlet.xml --> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:config/spring-servlet.xml</param-value> </init-param> --> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping></web-app>
另外一个目录下
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <bean name="/test1/helloworld" class="com.tgb.web.controller.HelloWorldController" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/"></property> <property name="suffix" value=".jsp"></property> </bean> </beans>
src目录下
package com.tgb.web.controller;import java.util.HashMap;import java.util.Map;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.web.servlet.ModelAndView;import org.springframework.web.servlet.mvc.Controller;public class HelloWorldController implements Controller {@Overridepublic ModelAndView handleRequest(HttpServletRequest arg0,HttpServletResponse arg1) throws Exception {System.out.println("-------hello tgb-----");String hello = "lsh hello 提高班";Map<String,Object> map = new HashMap<String,Object>();map.put("map1", "提高班1");map.put("map2", "提高班2");map.put("map3", "提高班3");//返回string数据//return new ModelAndView("/welcome","result",hello);//下面是返回map数据return new ModelAndView("/welcome","map",map);}}
http://localhost:8080/springquanbu/test1/helloworld
0 0
- SpringMVC配置文件
- SpringMVC配置文件
- springMvc配置文件
- SpringMVC配置文件
- SpringMVC配置文件
- springmvc配置文件
- springMVC配置文件
- SpringMVC 配置文件
- springmvc配置文件
- springMVC配置文件
- SpringMVC配置文件
- SpringMVC 配置文件
- springmvc 配置文件
- SpringMvc 配置文件
- springmvc配置文件
- SpringMVC 配置文件
- SpringMVC配置文件
- springmvc配置文件
- tomcat7+jdk的keytool生成证书 配置https
- Spyder在Windows环境下出现RuntimeError: Could not open file ../caffe/deploy.prototxt
- 框架模式 MVC 在Android中的使用
- 进度条
- 第二十四天作业3
- springmvc 配置文件
- git am *.patch err: has type 100644, expected 100755
- 线程学习--join()方法
- hiho一下 第139周 买零食
- LoadRunner中脚本回放问题及解决方法(下)
- 15_python_练习题——打印日历
- 块级元素与内联元素整理
- vmware kali 安装vm tools
- 【技巧】html中alt=的用法;