war包centos6.5上运行,freemarker运行报错,本地运行正常 5C

maven项目通过package打包在centos6.5上运行,freemarker运行报错,本地运行正常
报错内容:HTTP Status 500 - Could not resolve view with name 'views/weatherlog' in servlet with name 'springMVC'

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

<context:component-scan base-package="mongodb.*" />

<!-- MVC配置 代替 映射器和解析器 -->
<mvc:annotation-driven validator="validator" />

<!-- 校验器 -->
<!-- 以下 validator ConversionService 在使用 mvc:annotation-driven 会 自动注册 -->
<bean id="validator"
    class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
    <property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
    <!-- 如果不加默认到 使用classpath下的 ValidationMessages.properties -->
    <property name="validationMessageSource" ref="messageSource" />
</bean>
<bean id="messageSource"
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:messages" />
    <property name="fileEncodings" value="utf-8" />
    <property name="cacheSeconds" value="120" />
</bean>

<!-- 解析器注册 -->
<bean
    class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="stringHttpMessageConverter" />
        </list>
    </property>
</bean>
<!-- String类型解析器,允许直接返回String类型的消息 -->
<bean id="stringHttpMessageConverter"
    class="org.springframework.http.converter.StringHttpMessageConverter" />

<bean
    class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    <property name="prefix" value="/" />
    <property name="suffix" value=".ftl" />
    <property name="contentType" value="text/html; charset=utf-8" />
</bean>

<bean id="freemakerCongfig"
    class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"
    p:templateLoaderPath="/">
    <property name="freemarkerSettings">
        <props>
            <!-- 默认编码 -->
            <prop key="defaultEncoding">UTF-8</prop>
            <!-- 去掉数字格式化 -->
            <prop key="number_format">#.##</prop>
            <!-- 导入自定义内容 -->
            <prop key="auto_import">/ftl/index.ftl as f</prop>
            <!-- 处理空值为空字符串 -->
            <prop key="classic_compatible">true</prop>
        </props>
    </property>
    <property name="freemarkerVariables">
        <map>
            <entry key="left">
                <bean class="com.jdog.frameworks.freemarker.directive.FreeMarkerLeft" />
            </entry>
            <entry key="block">
                <bean
                    class="com.jdog.frameworks.freemarker.directive.FreeMarkerBlockDirective" />
            </entry>
        </map>
    </property>
</bean>

6个回答

请详细贴出错误日志,方便排查

joy460154849
joy460154849 Logger-->2018-01-14 13:05:12,0401 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:06:58,0886 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:07:08,0291 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version
一年多之前 回复

日志呢???????????

joy460154849
joy460154849 Logger-->2018-01-14 13:05:12,0401 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:06:58,0886 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:07:08,0291 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version
一年多之前 回复

运行.sh文件可以命令
#sh ./*.sh 的文件名

也可以先
#chmod +x .sh的文件名
#./
.sh的文件名

你好,有没有日志,不然不能分析出来问题原因。

joy460154849
joy460154849 Logger-->2018-01-14 13:05:12,0401 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:06:58,0886 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:07:08,0291 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version
一年多之前 回复

有日志容易找出问题原因。

joy460154849
joy460154849 Logger-->2018-01-14 13:05:12,0401 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:06:58,0886 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version Logger-->2018-01-14 13:07:08,0291 INFO{Version.java:30}-->HV000001: Hibernate Validator 5.4.1.Final-->org.hibernate.validator.internal.util.Version
一年多之前 回复

12-Jan-2018 10:25:05.234 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
12-Jan-2018 10:25:06.972 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'springMVC'
12-Jan-2018 10:25:10.579 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
12-Jan-2018 10:25:10.584 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
12-Jan-2018 10:25:11.810 严重 [http-nio-8001-exec-8] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [springMVC] in context with path [] threw exception [Could not resolve view with name 'views/weatherlog' in servlet with name 'springMVC'] with root cause
javax.servlet.ServletException: Could not resolve view with name 'views/weatherlog' in servlet with name 'springMVC'
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1237)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!