Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么我不能在SpringMVC中使用jsp:include传递参数?_Java_Spring_Jsp_Spring Mvc - Fatal编程技术网

Java 为什么我不能在SpringMVC中使用jsp:include传递参数?

Java 为什么我不能在SpringMVC中使用jsp:include传递参数?,java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,在我的Spring MVC项目中,在我的页面中,我想加载另一个页面。因此我使用jsp:include。但是我发现我总是在另一个页面中获取空参数值。我尝试创建一个Servlet项目,我可以 很好地获取值。我的代码怎么了 这是我的第一页: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %> <html xmlns="http://www.w3.org/1999/xhtml"> <h

在我的Spring MVC项目中,在我的页面中,我想加载另一个页面。因此我使用
jsp:include
。但是我发现我总是在另一个页面中获取空参数值。我尝试创建一个Servlet项目,我可以 很好地获取值。我的代码怎么了

这是我的第一页:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %> 
<html xmlns="http://www.w3.org/1999/xhtml">
<head> 
<title></title> 
<jsp:include page="../common/common.jsp" flush="true">
  <jsp:param name="gisType" value="baidu" />
 </jsp:include> 
</head> 
<body>

这是另一页:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<% 
 String gisType = "baidu";
  gisType = request.getParameter("gisType");
  System.out.print(gisType);
 %>
  <script type="text/javascript"> 
 var map;
 var gisType = "<%=gisType%>"; 
 alert(gisType);
 </script>

var映射;
var gisType=“”;
警报(gisType);
我的mvc配置文件如下所示:

    <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-4.0.xsd
      http://www.springframework.org/schema/mvc
      http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
      http://www.springframework.org/schema/tx
      http://www.springframework.org/schema/tx/spring-tx-4.0.xsd  
      http://www.springframework.org/schema/aop 
      http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
      http://www.springframework.org/schema/task
      http://www.springframework.org/schema/task/spring-task-4.0.xsd"
>  
<context:annotation-config /> 
<aop:aspectj-autoproxy />

<context:component-scan base-package="cn.com.project.**">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> 
</context:component-scan>

<mvc:annotation-driven /> 
<task:annotation-driven />
<mvc:default-servlet-handler/> 
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
p:prefix="" p:suffix=".jsp" />  
<bean id="annotationMethodHandlerAdapter"
    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list> 
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
        </list>
    </property>
</bean>


尝试使用${}表达式获取参数

<script type="text/javascript"> 
  var map;
  var gisType = "${param.gisType}"; 
  alert(gisType);
</script>

var映射;
var gisType=“${param.gisType}”;
警报(gisType);