applicationContext.xml配置问题

问题描述

applicationContext.xml中配置Freemarker中文乱码问题(Struts2+SpringFreemarker)FTL中获取到得值生成HTML页面中文显示正常,但就是FTL模板中原有的中文显示乱码,在网上找了些方法基本都一样,只剩下这个方法没试,但在过程中遇到下面的问题。希望大家帮下忙,或者对于这种问题还有别的解决方案吗?<beanid="freemarderConfig"class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"><propertyname="templateLoaderPath"value="/ftl/"/><!--错误Nosetterfoundforproperty'templateLoaderPath'inclass'org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer'--><propertyname="freemarkerVariables"><!--错误Nosetterfoundforproperty'freemarkerVariables'inclass'org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer'--><map><entrykey="xml_escape"value-ref="fmXmlEscape"/></map></property><propertyname="freemarkerSettings"><!--Nosetterfoundforproperty'freemarkerSettings'inclass'org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer'--><props><propkey="defaultEncoding">UTF-8</prop></props></property></bean>

spring-webmvc.jar这个包已有,看了下源代码,对应类中没有那些属性,是不是本版问题呢?另外用Freemarker生成HTML页面过程中,原FTL里的中文已经是乱码,而通过Action获取到得值的中文却显示正常FTL头部分也加入<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>也没起到效果附上相关代码ConfigurationfreemarkerCfg=newConfiguration();//加载模板freemarkerCfg.setServletContextForTemplateLoading(ServletActionContext.getServletContext(),"/WEB-INF/template");freemarkerCfg.setEncoding(Locale.CHINA,"UTF-8");//增加设置忽略异常freemarkerCfg.setTemplateExceptionHandler(TemplateExceptionHandler.IGNORE_HANDLER);//freemarkerCfg.setClassicCompatible(true);}try{//指定模板路径Templatetemplate=freemarkerCfg.getTemplate(templatePath,"UTF-8");template.setEncoding("UTF-8");StringhtmlPath=ServletActionContext.getServletContext().getRealPath("/")+targetHtmlName;FilehtmlFile=newFile(htmlPath);Writerout=newBufferedWriter(newOutputStreamWriter(newFileOutputStream(htmlFile),"UTF-8"));//处理模版template.process(sourcedata,out);out.flush();out.close();}catch(Exceptione){e.printStackTrace();}

看到的麻烦帮下吧!

解决方案

解决方案二:
在Web.xml中配置~Spring对编码的处理~百度可以查询代码~
解决方案三:
该回复于2011-04-15 09:45:43被版主删除
解决方案四:
看看是不是你eclipse项目中编码引起的
解决方案五:
引用1楼hpjianhua的回复:

在Web.xml中配置~Spring对编码的处理~百度可以查询代码~

是加入一个过滤器吗
解决方案六:
怎么没人来看看呢!另外在Spring1.2下Freemarker配置正常,但是换到Spring2.0下就出问题了。JAR包问题吧?

时间: 2024-09-07 15:15:56

applicationContext.xml配置问题的相关文章

Spring 中applicationContext.xml配置问题

问题描述 各位大神,麻烦帮我看看下面这个错怎讲解决.

applicationContext.xml联网正常断网出错

问题描述 我的applicationContext.xml配置为<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:/org/sprin

web app-项目找不到hibernate.cfg.xml也找不到applicationContext.xml

问题描述 项目找不到hibernate.cfg.xml也找不到applicationContext.xml 公司项目框架是ssh2使用注解开发.这两个文件是不是必须的?为什么会找不到呢web.xml配置如下<?xml version=""1.0"" encoding=""UTF-8""?> innermanager contextConfigLocation classpath:/config/spring/*.x

spring mvc-Spring mvc mybatis 核心文件applicationContext.xml读取路径的问题

问题描述 Spring mvc mybatis 核心文件applicationContext.xml读取路径的问题 我搭了一个框架,applicationcontext.xml文件不在src下也不在WEB-INF/classes下而是在WEB-INF/etc下(自己建的文件夹) 现在我的java类中想获取spring容器applicationContext 对象,核心xml文件总是说路径不对,试了好几种了,真心的求大神~~~~~ 严重: Servlet.service() for servlet

Spring配置文件详解 - applicationContext.xml文件路径

Spring配置文件详解 - applicationContext.xml文件路径 Java编程 超过1579次围观 spring的配置文件applicationContext.xml的默认地址在WEB-INF下,只要在web.xml中加入代码  <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener

在applicationContext.xml修改后,启动tomcat就报错了

问题描述 在applicationContext.xml修改后,启动tomcat就报错了 开发是遇到了这个错误,网上说jar包冲突,其实没有.说路径不对也没有.找大侠解决.谢谢. 解决方案 配置文件: autowire="byName"/> <bean id="inspectllservice" parent="txProxyHibernateTemplate"> <property name="target&q

applicationContext.xml 找不到元素 &amp;amp;#39;beans&amp;amp;#39; 的声明的问题

问题描述 applicationContext.xml 找不到元素 'beans' 的声明的问题 突然发现我的工程在断网的条件下无法使用,报错:cvc-elt.1: 找不到元素 'beans' 的声明. 上网查找后,仔细核对过. applicationContext.xml : <?xml version="1.0" encoding="UTF-8"?> xmlns="http://www.springframework.org/schema/

文档-applicationContext.xml解读出错

问题描述 applicationContext.xml解读出错 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ssf' defined in URL [file:/E:/apache-tomcat-7.0.67/webapps/myHobby/WEB-INF/classes/applicationContext.xml]: Invocation of init met

web xml-java web.xml 配置问题 velocity

问题描述 java web.xml 配置问题 velocity 1.没做任何修改的话需要localhost:8080/index这样指定才能进入index.vm,localhost:8080这样直接进入是进入404错误页面,我现在就把主页设置到了404错误里面,一直这样不是个办法 2.发现web.xml 中 welcome-file-list 这个无效,但是我把filter-mapping这个删了或者改成/index.vm就可以进入index.vm 但是后面的请求无法拦截 这里应该怎么修改? 如