我的源的ModelAndView返回源代碼以 「text/plain的」 類型
@RequestMapping(value = "/", method=RequestMethod.GET)
public ModelAndView mainPage() {
ModelAndView model = new ModelAndView("uploadPage");
model.addObject("msg", "hello world");
return model;
}
我的web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/mvc/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file></welcome-file>
</welcome-file-list>
</web-app>
,但在執行時 「炫魅法」,jsp頁面看起來像源代碼「 text/plain的」類型,而不是正常網頁...
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ page isELIgnored="false" %>
<title>Hello Spring MVC</title>
</head>
<body>
<h2>
<c:out value="${msg}" />
</h2>
</body>
</html>
幫助
但是從我所看到的'contentType =「text/html'!我看不到''text/plain'' –
我更新了帖子,添加了截圖 –
您能否提供web.xml? –