ssm项目controller进行页面跳转时return的页面出现异常

ssm项目controller进行页面跳转时return的页面出现异常_第1张图片
1.若return后的页面出现js,css报404,则说明样式被拦截,未被加载,此时需在springmvc的配置文件中添加如下内容

<!-- 将springmvc不能处理的请求交给tomcat -->
	<mvc:default-servlet-handler/>
	<mvc:annotation-driven></mvc:annotation-driven>
	
	<!-- 释放静态资源的路径,若不是放系统运行后会把这些资源进行拦截 -->
	<mvc:resources location="/css/" mapping="/css/**"></mvc:resources>
	<mvc:resources location="/fonts/" mapping="/fonts/**"></mvc:resources>
	<mvc:resources location="/img/" mapping="/img/**"></mvc:resources>
	<mvc:resources location="/js/" mapping="/js/**"></mvc:resources>
	<mvc:resources location="/materialize/" mapping="/materialize/**"></mvc:resources>

2.如果return后的页面显示出来,但css样式却未加载出来,需在jsp页面添加如下内容:

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="com.syn.television.bean.User"%>
<%
   String path=request.getContextPath();
   String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!--需添加的内容-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>main</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="" />
<base href=" <%=basePath%>"> <!--需添加的内容-->
<!-- css --> 
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="materialize/css/materialize.min.css" media="screen,projection" />
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/fancybox/jquery.fancybox.css" rel="stylesheet"> 
<link href="css/flexslider.css" rel="stylesheet" /> 
<link href="css/style.css" rel="stylesheet" />

</head>

你可能感兴趣的:(ssm中controller,ssm)