java中的接口是类吗
279
2023-03-28
浅谈springmvc的DispatcherServlet分析
本文介绍了springmvc的DispatcherServlet,分享给大家,具体如下:
一、程序
(一)web.xml文件中的内容
(二)src/main/resource/springmvc/spring-mvc.xml中的内容
p:prefix="/WEB-INF/view/" p:suffix=".jsp"/> (三)src/main/java/com/z/controller/IndexController.java中的内容 package com.z.controller; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class IndexController { @RequestMapping("/index.html") public ModelAndView getIndex(HttpServletRequest request) throws Exception { ModelAndView mav = new ModelAndView("index"); return mav; } } (四)src/main/webapp/WEB-INF/view/index.jsp <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<html>
p:prefix="/WEB-INF/view/" p:suffix=".jsp"/>
(三)src/main/java/com/z/controller/IndexController.java中的内容
package com.z.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class IndexController {
@RequestMapping("/index.html")
public ModelAndView getIndex(HttpServletRequest request) throws Exception {
ModelAndView mav = new ModelAndView("index");
return mav;
}
}
(四)src/main/webapp/WEB-INF/view/index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
This is my JSP page.
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~