Spring-MVC中ModelAndView对象所添加的内容在前端用EL表达式获取不到的问题
2017-02-28 17:55
399 查看
原来是IntelliJ IDEA默认生成的web.xml文档的头部不正确
将web.xml的头部改成如下即可
<!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> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>SpringMVC1</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>SpringMVC1</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
将web.xml的头部改成如下即可
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:web="http://xmlns.jcp.org/xml/ns/javaee"> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>SpringMVC1</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>SpringMVC1</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
相关文章推荐
- SpringBind对象到页面时,用ajax提交form表单内容,后台无法获取绑定对象问题
- Android WebView shouldOverrideUrlLoading()中url添加参数获取不到问题解决
- 关于asp.net mvc 使用ueditor添加内容 前端只显示原样标签的问题
- Spring MVC ModelAndView addObject 使用EL表达式失效
- spring mvc DispatcherServlet详解之三---request通过ModelAndView中获取View实例的过程
- Spring MVC ModelAndView
- springmvc controller 映射对象乱码问题
- asp.net mvc 外网获取不到port问题解决
- SpringMVC中ModelAndView addObject()设置的值jsp取不到的问题
- MVC-通过对象获取整个表单内容
- SpringMVC ModelAndView方法与模板传参接收不到问题
- 160615、Spring3 MVC 拦截器拦截不到的问题
- springmvc+mybatis+maven项目集成的时候遇到一个问题,项目搭起来以后,http请求怎么都进不到controller中,页面直接返回404错误,控制台没有报任何错误,请大神帮我看看
- JS中获取ModelAndView对象中值
- ssh下:系统初始化实现ServletContextListener接口时,获取spring中数据层对象无效的问题
- js获取ModelAndView值的问题
- Spring的@Value获取不到值的问题
- backbone+springMVC 前端后台保存model数据的属性值为null问题
- Maven +SpringMVC 搭建时候遇到视图view跳转失败问题
- Spring MVC @ModelAttribute 获取不到值