freemarker: Template not found for name "xxx.ftl". 5C

报错信息:

 freemarker.template.TemplateNotFoundException: Template not found for name "login.ftl".
The name was interpreted by this TemplateLoader: MultiTemplateLoader(loader1 = org.springframework.ui.freemarker.SpringTemplateLoader@3d5c089b, loader2 = ClassTemplateLoader(resourceLoaderClass=org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer, basePackagePath="" /* relatively to resourceLoaderClass pkg */)).
    at freemarker.template.Configuration.getTemplate(Configuration.java:1833)
    at freemarker.template.Configuration.getTemplate(Configuration.java:1646)
    at com.csaarg.util.framework.FreeMarkerUtil.create(FreeMarkerUtil.java:35)
    at com.csaarg.sharedvip.controller.ForwardController.login(ForwardController.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    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)

FreeMarker 配置:

<bean id="freeMarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="defaultEncoding" value="UTF-8"/>
    <!-- 模板路径 -->
    <property name="templateLoaderPath" value="/WEB-INF/freeMarker/"/>
    <!-- 配置文件 -->
    <property name="freemarkerSettings" ref="freemarkerSettings"/>
    <!-- 自定义指令 -->
    <property name="freemarkerVariables">
        <map>
            <entry key="xml_escape" value-ref="fmXmlEscape"/>
            <!--<entry key="view_url" value="http://localhost:8299/Store/content/css/"/>-->
            <!--<entry key="JS_URL" value="http://localhost:8299/Store/content/js/"/>-->
        </map>
    </property>
</bean>

<!-- 配置文件 -->
<bean id="freemarkerSettings" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="location" value="classpath:properties/freemarker.properties"/>
</bean>
<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape"/>

<!--识图解析器-->
<bean id="freeMarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/>
    <property name="viewNames" value="*.ftl"/>
    <property name="contentType" value="text/html; charset=utf-8"/>
    <property name="cache" value="true"/>
    <property name="suffix" value=""/>
    <!--    <property name="exposeRequestAttributes" value="true" />
        <property name="exposeSessionAttributes" value="true" />
        <property name="exposeSpringMacroHelpers" value="true" /> -->
    <property name="order" value="0"/>
</bean>
<!--对模型视图名称的解析,即在模型视图名称添加前后缀 通用解析器-->
<bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value=""/>
    <property name="viewNames" value="*.html"/>
    <property name="suffix" value=""/>
    <property name="viewClass" value="org.springframework.web.servlet.view.InternalResourceView"/>
    <property name="order" value="1"></property>
</bean> 

Controller:

 /**
 * 转发
 */
@Controller
public class ForwardController {

    @Autowired
    private static FreeMarkerConfigurer freeMarkerConfigurer;

    @Autowired
    private FreeMarkerConfig freeMarkerConfig;

    /**
     * 登录
     *
     * @return
     */
    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login(HttpServletRequest request) {

        FreeMarkerUtil.create(request, freeMarkerConfig, "login.ftl", null, "/WEB-INF/freeMarker", "login.html");

        return "/view/login.html";
    }

}

工具类:

    public class FreeMarkerUtil {

    private FreeMarkerUtil() {
    }

    /**
     * 生成 HTML 静态页面
     *
     * @param request
     * @param freeMarkerConfig
     * @param templateName     模板的名称
     * @param model            生成模板需要的数据
     * @param filePath         相对于 web 容器的路径
     * @param fileName         要生成的文件的名称,带扩展名
     */
    public static void create(HttpServletRequest request, FreeMarkerConfig freeMarkerConfig, String templateName,
                              Map<String, Object> model, String filePath,
                              String fileName) {
        Writer out = null;
        try {
            Template template = freeMarkerConfig.getConfiguration()
                    .getTemplate(templateName);
            String htmlPath = request.getSession().getServletContext()
                    .getRealPath(filePath)
                    + "/" + fileName;
            File htmlFile = new File(htmlPath);
            if (!htmlFile.getParentFile().exists()) {
                htmlFile.getParentFile().mkdirs();
            }
            if (!htmlFile.exists()) {
                htmlFile.createNewFile();
            }
            out = new OutputStreamWriter(new FileOutputStream(htmlPath), "UTF-8");
            template.process(model, out);
            out.flush();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TemplateException e) {
            e.printStackTrace();
        } finally {
            try {
                out.close();
                out = null;
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

webapp 目录结构:

报错行:

 Template template = freeMarkerConfig.getConfiguration().getTemplate(templateName);

参照配置:https://my.oschina.net/HuifengWang/blog/300461

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
struts2.3 + ajax 出现黄色页面 in template "template/ajax/head.ftl" at line 45, column 28]

struts2.3 + ajax 网页出现异常: FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!) The following has evaluated to null or missing: ==> parameters.parseContent [in template "template/ajax/head.ftl" at line 45, column 28] Tip: It's the step after the last dot that caused this error, not those before it. Tip: If the failing expression is known to be legally refer to something that's null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? FTL stack trace ("~" means nesting-related): - Failed at: ${parameters.parseContent?string} [in template "template/ajax/head.ftl" at line 45, column 26] Java stack trace (for programmers): freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:116) at freemarker.core.UnexpectedTypeException.newDesciptionBuilder(UnexpectedTypeException.java:60) at freemarker.core.UnexpectedTypeException.<init>(UnexpectedTypeException.java:40) at freemarker.core.BuiltInsForMultipleTypes$stringBI._eval(BuiltInsForMultipleTypes.java:617) at freemarker.core.Expression.eval(Expression.java:78) at freemarker.core.Expression.evalAndCoerceToString(Expression.java:82) at freemarker.core.DollarVariable.accept(DollarVariable.java:40) at freemarker.core.Environment.visit(Environment.java:312) at freemarker.core.MixedContent.accept(MixedContent.java:62) at freemarker.core.Environment.visit(Environment.java:312) at freemarker.core.Environment.process(Environment.java:290) at freemarker.template.Template.process(Template.java:312) at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:158) at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:584) at org.apache.struts2.components.UIBean.end(UIBean.java:538) at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42) at org.apache.jsp.chapter15.ajaxform_jsp._jspx_meth_s_005fhead_005f0(ajaxform_jsp.java:188) at org.apache.jsp.chapter15.ajaxform_jsp._jspService(ajaxform_jsp.java:123) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2503) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2492) 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) ![图片说明](https://img-ask.csdn.net/upload/201601/05/1451982012_346311.png) 有哪个大神遇到过这样的问题么,最后是怎么解决的?

SpringMVC+Freemarker实现国际化

页面显示:freemarker.core.InvalidReferenceException: Expression springMacroRequestContext is undefined on line 28, column 24 in spring.ftl. 控制台显示:Nov 22, 2017 10:17:57 AM freemarker.log.JDK14LoggerFactory$JDK14Logger error SEVERE: Expression springMacroRequestContext is undefined on line 28, column 24 in spring.ftl. The problematic instruction: ---------- ==> ${springMacroRequestContext.getMessage(code)} [on line 28, column 22 in spring.ftl] in user-directive spring.message [on line 21, column 40 in loginres.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression springMacroRequestContext is undefined on line 28, column 24 in spring.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134) at freemarker.core.Dot._getAsTemplateModel(Dot.java:78) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:86) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:208) at freemarker.core.Macro$Context.runMacro(Macro.java:163) at freemarker.core.Environment.visit(Environment.java:601) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:106) at freemarker.core.Environment.visit(Environment.java:208) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:208) at freemarker.core.Environment.process(Environment.java:188) at freemarker.template.Template.process(Template.java:237) at com.owera.xaps.web.app.util.Freemarker.parseTemplate(Freemarker.java:152) at com.owera.xaps.web.app.security.LoginServlet.printLoginPage(LoginServlet.java:159) at com.owera.xaps.web.app.security.LoginServlet.doRequest(LoginServlet.java:113) at com.owera.xaps.web.app.security.LoginServlet.doGet(LoginServlet.java:186) at javax.servlet.http.HttpServlet.service(HttpServlet.java:620) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622) at java.lang.Thread.run(Thread.java:748)

maven项目报错Encountered "-", but was expecting: "="]

同一个项目组的,别人的项目就可以启动并且正常运行。真的不知道到底是哪里出了问题。开发工具,换了好几个版本。用了me6.5,2017.都是报这个错 别的tomcat 。maven版本。jdk。都是一样的。 唯一的不同。。和他们操作系统不一样,,千万不要跟我说让我重新装个win7.。。那我会崩溃的。。 在网上搜索同样的问题,别人说是什么编码的关系。我已经把所有我能改的编码都改成了UTF-8,还是不可以。 求大神解救 Servlet.service() for servlet [springmvc] in context with path [/shopPlat] threw exception [Request processing failed; nested exception is org.springframework.context.ApplicationContextException: Failed to parse FreeMarker template for URL [swms/swmssys/system/unit.html]; nested exception is freemarker.core.ParseException: Parsing error in template "swms/swmssys/system/unit.html" in line 1, column 41: Encountered "-", but was expecting: "="] with root cause freemarker.core.ParseException: Parsing error in template "swms/swmssys/system/unit.html" in line 1, column 41: Encountered "-", but was expecting: "=" at freemarker.core.FMParser.generateParseException(FMParser.java:4672) at freemarker.core.FMParser.jj_consume_token(FMParser.java:4543) at freemarker.core.FMParser.Include(FMParser.java:1681) at freemarker.core.FMParser.FreemarkerDirective(FMParser.java:2361) at freemarker.core.FMParser.Content(FMParser.java:2593) at freemarker.core.FMParser.OptionalBlock(FMParser.java:2761) at freemarker.core.FMParser.Root(FMParser.java:2933) at freemarker.template.Template.<init>(Template.java:193) at freemarker.cache.TemplateCache.loadTemplate(TemplateCache.java:419) at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:330) at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:205) at freemarker.template.Configuration.getTemplate(Configuration.java:740) at freemarker.template.Configuration.getTemplate(Configuration.java:673) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.getTemplate(FreeMarkerView.java:351) at org.

freemarker报错,本身就是String类型的字符串

FreeMarker template error: For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), or "template output" , but this has evaluated to a method+sequence (wrapper: f.e.b.SimpleMethodModel): ==> t.getTime [in template "views/tempweather.ftl" at line 155, column 47] ---- Tip: Maybe using obj.something instead of obj.getSomething will yield the desired value. ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${t.getTime} [in template "views/tempweather.ftl" at line 155, column 45] ---- Java stack trace (for programmers): ---- freemarker.core.NonStringOrTemplateOutputException: [... Exception message was already printed; see it above ...] at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:492) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:374) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:96) at freemarker.core.DollarVariable.accept(DollarVariable.java:59) at freemarker.core.Environment.visit(Environment.java:363) at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:316) at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:272) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:243) at freemarker.core.Environment.visitIteratorBlock(Environment.java:596) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) at freemarker.core.Environment.visit(Environment.java:327) at freemarker.core.Environment.visit(Environment.java:333) at freemarker.core.Environment.visit(Environment.java:333) at freemarker.core.Environment.process(Environment.java:306) at freemarker.template.Template.process(Template.java:386) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:367) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:284) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:234) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257) 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:617) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582) Logger-->2017-03-16 18:44:25,0449 WARN{Slf4jLog.java:89}-->/TempWeather/list.do-->org.mortbay.log FreeMarker template error: For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), or "template output" , but this has evaluated to a method+sequence (wrapper: f.e.b.SimpleMethodModel): ==> t.getTime [in template "views/tempweather.ftl" at line 155, column 47] ---- Tip: Maybe using obj.something instead of obj.getSomething will yield the desired value. ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${t.getTime} [in template "views/tempweather.ftl" at line 155, column 45] ---- Java stack trace (for programmers): ---- freemarker.core.NonStringOrTemplateOutputException: [... Exception message was already printed; see it above ...] at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:492) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:374) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:96) at freemarker.core.DollarVariable.accept(DollarVariable.java:59) at freemarker.core.Environment.visit(Environment.java:363) at freemarker.core.IteratorBlock$IterationContext.executedNestedContentForCollOrSeqListing(IteratorBlock.java:316) at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:272) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:243) at freemarker.core.Environment.visitIteratorBlock(Environment.java:596) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:108) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94) at freemarker.core.Environment.visit(Environment.java:327) at freemarker.core.Environment.visit(Environment.java:333) at freemarker.core.Environment.visit(Environment.java:333) at freemarker.core.Environment.process(Environment.java:306) at freemarker.template.Template.process(Template.java:386) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:367) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:284) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:234) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257) 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:617) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:440) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:326) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:926) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404) at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

IDEA webSpringMVC项目整合Freemarker时返回视图名必须以.ftl后缀结尾

由于刚进公司,使用的框架是SSM,前端使用Freemarker,所以自己新建一个项目学习一下Freemarker。 Freemarker使用最新的2.3.29版本,Spring使用4.3.18,在网站查找配置了Freemarker的视图解析之后, Controller层返回ModelAndView却需要以.ftl结尾才能解析,否则找不到页面,因此贴出代码,让知道的小伙伴给一些意见建议,非常感谢,刚入行,还没有分,希以后有了肯定补上,望帮助一下,非常感谢。 ![图片说明](https://img-ask.csdn.net/upload/201909/20/1568983203_676907.png) ![图片说明](https://img-ask.csdn.net/upload/201909/20/1568983252_81938.png) ![图片说明](https://img-ask.csdn.net/upload/201909/20/1568983502_770695.png) ![图片说明](https://img-ask.csdn.net/upload/201909/20/1568983510_336516.png) 我个人思考了一下,应该是配置的问题,但问题出在哪儿不知道。

springboot整合freemarker中,templates下有error.ftl,为什么不能访问

![图片说明](https://img-ask.csdn.net/upload/201911/17/1573985347_223141.png)![图片说明](https://img-ask.csdn.net/upload/201911/17/1573985358_854497.png) 浏览器输入错误地址,给出的是spring的错误页面,没有进入我写的页面 error.ftl.而且输入http://localhost:8080,也没有进入index.ftl.

把freemarker模板放在jar中,经常报java.io.FileNotFoundException错误,有何办法吗?

我把freemarker模板放在jar中,每次修改后,用ant把所有源文件都打到jar也包括ftl文件,如果仅修改ftl文件,则不需要在tomcat中reload该应用(尽管jar文件被更新了但jar没有重新装载吧,刷新页面会发现freemarker模板的改动生效,似乎从jar包中取模板仅是使用路径),而改过类文件后需要reload重新装载jar,但是reload之后,却又找不到其中的ftl文件了,报错如下: java.io.FileNotFoundException: JAR entry com/originsys/manager/systemservice/view/cachelist.ftl not found in D:\apache-tomcat\webapps\eap2\WEB-INF\lib\eap-manager.jar at 。。。。。。 但是ftl文件的确在那个jar中,只好重启tomcat才能找到,重启tomcat比reload应用慢多了,这样弄效率太低了,请问高手:reload应用后找不到jar中的ftl文件是什么原因?如何才能够找到呢? [b]问题补充:[/b] playfish:打包到jar中也是freemarker推荐的一种做法,因为这样可以保证模板与应用一起发布,提供了ClassTemplateLoader来加载基于类路径的模板。freemarker更推荐多加载器,当文件系统中找不到时则加载类路径中的。我就是这么设置的,但我不想同时修改两份,所有只保留jar中的。 lovewhzlq :我还没找到规律,大部分情况是会出错,如果改类重新发布并reload似乎不出错。freemarker文档中指出,freemarker模板是缓存的,当模板被改变时则刷新缓存,但打到jar中的模板被修改时不能实时获得修改的通知--也许与这有关,但我不知如何调整能避免这个问题 [b]问题补充:[/b] [b]找到规律了:[/b] tomcat重启后为正常状态,此时reload或者从eclipse通过ant发布(打包jar到lib下)均正常,但如果修改后再打包发布,与reload无关,则会报找不到ftl文件。 [b]也就是说,当jar文件被真正修改(增加或修改了类或ftl,使jar文件大小发生了变化,简单修改如删除一句注释则没有影响),则会找不到ftl文件,即使reload也不起作用,只能重启。[/b]

freemarker.core.NonStringException 的问题

页面: ![图片说明](https://img-ask.csdn.net/upload/201711/15/1510737785_645786.png) ![图片说明](https://img-ask.csdn.net/upload/201711/15/1510737804_65717.png) 后台: ![图片说明](https://img-ask.csdn.net/upload/201711/15/1510737819_901369.png) ![图片说明](https://img-ask.csdn.net/upload/201711/15/1510737836_874409.png) 现在页面上取枚举类的name属性一直报NonStringException异常, 但是枚举类中name属性确实是String类型,控制台可以正常打印,value属性也能正常取.求大神指点一下.

用 freemarker遍历list报错

freemarker.template.TemplateException: Expected hash. c evaluated instead to freemarker.template.SimpleSequence on line 37, column 57 in WEB-INF/t/cms/www/red/member/我的活动报名列表.html. at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:135) at freemarker.core.Dot._getAsTemplateModel(Dot.java:78) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:179) at freemarker.core.Environment.visit(Environment.java:417) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.IfBlock.accept(IfBlock.java:82) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:210) at freemarker.core.Environment.process(Environment.java:190) at freemarker.template.Template.process(Template.java:237) at com.jeecms.common.web.springmvc.SimpleFreeMarkerView.renderMergedTemplateModel(SimpleFreeMarkerView.java:112) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:723) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.jeecms.common.web.ProcessTimeFilter.doFilter(ProcessTimeFilter.java:38) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:617) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1778) at java.lang.Thread.run(Thread.java:662)

Freemarker的ftl文件包含jsp问题

按照Freemarker文档所示,我想要在一个ftl文件中包含一个jsp文件:<#include "../../../view/public/header.jsp">。 可是,在生成静态页面时一直提示:Error reading included file ../../../view/public/header.jsp The problematic instruction: ---------- ==> include "../../../view/public/header.jsp"。 另外,本人试了一下在ftl文件的上一级目录下引入header.jsp文件,然后在试着包含jsp文件就没有问题:<#include "header.jsp">。所以,我就怀疑是不是"../../../"Freemarker没解析出来? 希望有知道的高手帮忙解答,本人不胜感激!

freemarker 引入ftl的问题求解惑

我这里使用index.ftl 和 button.ftl,并且在同一级目录 button.ftl就是一个生成简单的a标签按钮 spring中配置文件, ``` <prop key="auto_import">/macro/index.ftl as ui</prop> ``` 我在index.ftl中使用include: ``` <#include "button.ftl"/> ``` 提示: java.io.FileNotFoundException: Template button.ftl not found. 但是我把button.ftl拷贝到index.ftl中时,就能正常使用,所以就很难理解,使用include为什么会出现找到不模板的问题

thymeleaf循环list<>时报错,求大神帮助!

小弟刚学thymeleaf,在springboot框架中用th:each循环list数据时总是报错,求大神帮助! 后台代码 ``` public String index(HttpServletRequest request, HttpServletResponse response, Model model) { List<TpWarningcontentEntity> bcs = tpWarningcontentService.queryList(); //String str = JSON.toJSONString(bcs); model.addAttribute("bcs", bcs.toString()); return "shouye"; } ``` 前台代码: ``` <div class="col-sm-12 text-center border_b" th:each="bcs : ${bcs}"> <div class="index_title" th:text="${bcs.title}" ></div> </div> ``` 后台报错 freemarker.core.NonHashException: For "." left-hand operand: Expected a hash, but this has evaluated to a string (wrapper: f.t.SimpleScalar): ==> bcs [in template "shouye.html" at line 443, column 118] ---- FTL stack trace ("~" means nesting-related): - Failed at: ${bcs.title} [in template "shouye.html" at line 443, column 116] ---- at freemarker.core.Dot._eval(Dot.java:48) at freemarker.core.Expression.eval(Expression.java:101) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:331) at freemarker.core.Environment.visit(Environment.java:337) at freemarker.core.Environment.process(Environment.java:310) at freemarker.template.Template.process(Template.java:383) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:389) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:302) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:253) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:178) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1371) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1117) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1056) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:112) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at io.renren.common.xss.XssFilter.doFilter(XssFilter.java:31) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387) at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:118) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 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) 前台报错: bcs [in template "shouye.html" at line 443, column 118] ---- FTL stack trace ("~" means nesting-related): - Failed at: ${bcs.title} [in template "shouye.html" at line 443, column 116] ---- Java stack trace (for programmers): ---- freemarker.core.NonHashException: [... Exception message was already printed; see it above ...] at freemarker.core.Dot._eval(Dot.java:48) at freemarker.core.Expression.eval(Expression.java:101) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:331) at freemarker.core.Environment.visit(Environment.java:337) at freemarker.core.Environment.process(Environment.java:310) at freemarker.template.Template.process(Template.java:383) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:389) 网上搜了好多资料都没有找到具体原因。希望大神帮助!

ssh2结构,FreeMarker template error,这是什么错误

[code="java"]FreeMarker template error! Method public java.lang.String com.opensymphony.xwork2.validator.validators.ValidatorSupport.getMessage(java.lang.Object) threw an exception when invoked on com.opensymphony.xwork2.validator.validators.RequiredStringValidator@161c9d1 The problematic instruction: ---------- ==> ${validator.getMessage(action)?js_string} [on line 50, column 26 in template/xhtml/form-close-validate.ftl] in include "/${parameters.templateDir}/xhtml/form-close-validate.ftl" [on line 25, column 1 in template/xhtml/form-close.ftl] ---------- Java backtrace for programmers: ---------- freemarker.template.TemplateModelException: Method public java.lang.String com.opensymphony.xwork2.validator.validators.ValidatorSupport.getMessage(java.lang.Object) threw an exception when invoked on com.opensymphony.xwork2.validator.validators.RequiredStringValidator@161c9d1 at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136) at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.StringBuiltins$StringBuiltIn._getAsTemplateModel(StringBuiltins.java:71) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.Expression.getStringValue(Expression.java:93) at freemarker.core.DollarVariable.accept(DollarVariable.java:76) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160) at freemarker.core.Environment.visit(Environment.java:351) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160) at freemarker.core.Environment.visit(Environment.java:351) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.Environment.include(Environment.java:1375) at freemarker.core.Include.accept(Include.java:155) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:196) at freemarker.core.Environment.process(Environment.java:176) at freemarker.template.Template.process(Template.java:232) at org.apache.struts2.components.template.FreemarkerTemplateEngine.renderTemplate(FreemarkerTemplateEngine.java:168) at org.apache.struts2.components.UIBean.mergeTemplate(UIBean.java:530) at org.apache.struts2.components.UIBean.end(UIBean.java:484) at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43) at org.apache.jsp.index_jsp._jspx_meth_s_005fform_005f0(index_jsp.java:166) at org.apache.jsp.index_jsp._jspService(index_jsp.java:90) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:415) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.NullPointerException at com.opensymphony.xwork2.validator.DelegatingValidatorContext$LoggingValidationAware.<init>(DelegatingValidatorContext.java:234) at com.opensymphony.xwork2.validator.DelegatingValidatorContext.makeValidationAware(DelegatingValidatorContext.java:193) at com.opensymphony.xwork2.validator.DelegatingValidatorContext.<init>(DelegatingValidatorContext.java:53) at com.opensymphony.xwork2.validator.validators.ValidatorSupport.getMessage(ValidatorSupport.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616) at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113) ... 67 more[/code] jsp: [code="java"]<%@ page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %> <%@ taglib prefix="s" uri="/struts-tags" %> <%@ page isELIgnored="false"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>My JSP 'LoginView.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <s:fielderror></s:fielderror> <s:form name="form" action="LoginAction_login" method="post" validate="true"> <s:textfield label="用户名" id="view.username" name="view.username"></s:textfield> <s:password label="密码" id="view.password" name="view.password"></s:password> <s:submit value="登陆"></s:submit> </s:form> </body> </html>[/code] ssh2结构 控制台和日志都没报错 上面的错误,jsp页面上提示的,不知道怎么回事,请帮忙,多谢

FreeMarker For "?c" left-hand operand: Expected a number or boolean, but this evaluated to a string (wrapper: f.t.SimpleScalar) 不明白这个错和我的写法有什么关系?

这是我的语法 <#if datas?? && (datas?size > 0)> <#list datas as head> { "sourceId":"${head.sourceId?c}", "operaType":"${head.operaType!}" } </#list> </#if> 如果改成以下,就不报错,但是我就没办法处理超过四位数带逗号的数字格式 <#if datas?? && (datas?size > 0)> <#list datas as head> { "sourceId":"${head.sourceId}", "operaType":"${head.operaType!}" } </#list> </#if> 其中 ${head.sourceId} 这个数值实际为"1480",请问这种不能加?c的语法吗?还是只能数字才可以加?c 我把"${head.sourceId?c}"改成${head.sourceId?c} 也报相同的cuo'wu

FreeMarkerView 加载 的 疑问?

Logger-->DEBUG{FreeMarkerView.java:279}-Rendering FreeMarker template [yd/binding.html] in FreeMarkerView 'yd/binding' Logger-->DEBUG{_Log4jLoggerFactory.java:45}-TemplateLoader.findTemplateSource("yd/binding_zh_CN.html"): Not found Logger-->DEBUG{_Log4jLoggerFactory.java:45}-TemplateLoader.findTemplateSource("yd/binding_zh.html"): Not found Logger-->DEBUG{_Log4jLoggerFactory.java:45}-TemplateLoader.findTemplateSource("yd/binding.html"): Found 为啥要如此寻找,_zh_CN _zh ?

js中使用freemarker

我希望在js的<script type="text/javascript"></script>中使用freemarker的指令,如<#list>等,应该怎么使用。

freemarker #assign 问题

java后端: List<String> signDays = new ArrayList<String>(); ...list.add("1") list.add("2")... request.setAttribute("signDays", signDays); 用了freemarker 的前端: <#assign num = "${l}"/> <#assign signDays = "${signDays}"/> <#if signDays?seq_contains(num)> 我反复看了 很多遍 感觉没错 最后报错: [ERROR] 09:24:44.152 [http-apr-8088-exec-7] freemarker.runtime - Error executing FreeMarker template freemarker.core.NonStringOrTemplateOutputException: For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), or "template output" , but this has evaluated to a sequence (wrapper: f.t.SimpleSequence): ==> signDays [in template "point/point.htm" at line 72, column 88]

为什么我用freemarker导出word文档,导出的里面全是ftl文字内容,而不是正确的格式呢?找了好久了都没找出来问题。。。

java代码: ``` import freemarker.template.Configuration; import freemarker.template.DefaultObjectWrapper; import freemarker.template.Template; import freemarker.template.TemplateExceptionHandler; import lombok.extern.slf4j.Slf4j; import sun.misc.BASE64Encoder; import java.io.*; import java.util.*; @Slf4j public class WordReporter { private static final String ENCODING = "UTF-8"; private static Configuration cfg = new Configuration(); //初始化cfg static { //设置模板所在文件夹 try { cfg.setDirectoryForTemplateLoading(new File("D:/")); } catch (IOException e) { e.printStackTrace(); } // setEncoding这个方法一定要设置国家及其编码,不然在ftl中的中文在生成html后会变成乱码 cfg.setEncoding(Locale.getDefault(), ENCODING); // 设置对象的包装器 cfg.setObjectWrapper(new DefaultObjectWrapper()); // 设置异常处理器,这样的话就可以${a.b.c.d}即使没有属性也不会出错 cfg.setTemplateExceptionHandler(TemplateExceptionHandler.IGNORE_HANDLER); } //获取模板对象 public static Template getTemplate(String templateFileName) throws IOException { return cfg.getTemplate(templateFileName, ENCODING); } /** * 据数据及模板生成文件 * @param data Map的数据结果集 * @param templateFileName ftl模版文件名 * @param outFilePath 生成文件名称(可带路径) */ public static File crateFile(Map<String, Object> data, String templateFileName, String outFilePath) { Writer out = null; File outFile = new File(outFilePath); try { // 获取模板,并设置编码方式,这个编码必须要与页面中的编码格式一致 Template template = getTemplate(templateFileName); if (!outFile.getParentFile().exists()) { outFile.getParentFile().mkdirs(); } out = new OutputStreamWriter(new FileOutputStream(outFile), ENCODING); // 处理模版 template.process(data, out); out.flush(); log.info("由模板文件" + templateFileName + "生成" + outFilePath + "成功."); } catch (Exception e) { log.error("由模板文件" + templateFileName + "生成" + outFilePath + "出错"); e.printStackTrace(); } finally { try { if (out != null) { out.close(); } } catch (IOException e) { log.error("关闭Write对象出错", e); e.printStackTrace(); } } return outFile; } public static void main(String[] args) { try { Map<String, Object> data = new HashMap<String, Object>(); List<Map<String, String>> newsList = new ArrayList<Map<String, String>>(); for(int i=1;i<=5;i++){ Map<String, String> map=new HashMap<String, String>(); map.put("stName", "字段姓名"+i); newsList.add(map); } data.put("list",newsList); crateFile(data, "a.ftl", "D:/aaa.docx"); } catch (Exception e) { e.printStackTrace(); } } } ``` ftl文件内容: ``` <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpsCustomData="http://www.wps.cn/officeDocument/2013/wpsCustomData" mc:Ignorable="w14 w15 wp14"> <w:body> <#list list as data> <w:tbl> <w:tblPr> <w:tblStyle w:val="4"/> <w:tblW w:w="0" w:type="auto"/> <w:tblInd w:w="0" w:type="dxa"/> <w:tblBorders> <w:top w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:left w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:bottom w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:right w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:insideH w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:insideV w:val="single" w:color="auto" w:sz="4" w:space="0"/> </w:tblBorders> <w:tblLayout w:type="autofit"/> <w:tblCellMar> <w:left w:w="108" w:type="dxa"/> <w:right w:w="108" w:type="dxa"/> </w:tblCellMar> </w:tblPr> <w:tblGrid> <w:gridCol w:w="2840"/> <w:gridCol w:w="2841"/> <w:gridCol w:w="2841"/> </w:tblGrid> <w:tr> <w:tblPrEx> <w:tblBorders> <w:top w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:left w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:bottom w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:right w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:insideH w:val="single" w:color="auto" w:sz="4" w:space="0"/> <w:insideV w:val="single" w:color="auto" w:sz="4" w:space="0"/> </w:tblBorders> <w:tblCellMar> <w:left w:w="108" w:type="dxa"/> <w:right w:w="108" w:type="dxa"/> </w:tblCellMar> </w:tblPrEx> <w:tc> <w:tcPr> <w:tcW w:w="2840" w:type="dxa"/> </w:tcPr> <w:p> <w:pPr> <w:rPr> <w:rFonts w:hint="eastAsia" w:eastAsiaTheme="minorEastAsia"/> <w:vertAlign w:val="baseline"/> <w:lang w:val="en-US" w:eastAsia="zh-CN"/> </w:rPr> </w:pPr> <w:r> <w:rPr> <w:rFonts w:hint="eastAsia"/> <w:vertAlign w:val="baseline"/> <w:lang w:val="en-US" w:eastAsia="zh-CN"/> </w:rPr> <w:t>1</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="2841" w:type="dxa"/> </w:tcPr> <w:p> <w:pPr> <w:rPr> <w:rFonts w:hint="eastAsia" w:eastAsiaTheme="minorEastAsia"/> <w:vertAlign w:val="baseline"/> <w:lang w:val="en-US" w:eastAsia="zh-CN"/> </w:rPr> </w:pPr> <w:r> <w:rPr> <w:rFonts w:hint="eastAsia"/> <w:vertAlign w:val="baseline"/> <w:lang w:val="en-US" w:eastAsia="zh-CN"/> </w:rPr> <w:t>1</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:tcPr> <w:tcW w:w="2841" w:type="dxa"/> </w:tcPr> <w:p> <w:pPr> <w:rPr> <w:rFonts w:hint="default" w:eastAsiaTheme="minorEastAsia"/> <w:vertAlign w:val="baseline"/> <w:lang w:val="en-US" w:eastAsia="zh-CN"/> </w:rPr> </w:pPr> <w:r> <w:rPr> <w:rFonts w:hint="eastAsia"/> <w:vertAlign w:val="baseline"/> <w:lang w:val="en-US" w:eastAsia="zh-CN"/> </w:rPr> <w:t>${data.stName}</w:t> </w:r> </w:p> </w:tc> </w:tr> </w:tbl> </#list> <w:p> <w:bookmarkStart w:id="0" w:name="_GoBack"/> <w:bookmarkEnd w:id="0"/> </w:p> <w:sectPr> <w:pgSz w:w="11906" w:h="16838"/> <w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:header="851" w:footer="992" w:gutter="0"/> <w:cols w:space="425" w:num="1"/> <w:docGrid w:type="lines" w:linePitch="312" w:charSpace="0"/> </w:sectPr> </w:body> </w:document> ``` ![图片说明](https://img-ask.csdn.net/upload/201912/11/1576078986_743908.png) 导出的文件里面全是ftl文件里的文字内容

SpringMVC 整合FreeMarker时的问题

springMVCr的配置如下: [code="java"] <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package="com.ahmi.controller" /> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" /> <bean id="freemarkerResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="order" value="1"/> <property name="prefix" value="/WEB-INF/freemarker"/> <property name="suffix" value=".ftl"/> <property name="contentType" value="text/html;charset=utf-8"/> <property name="viewClass"> <value>org.springframework.web.servlet.view.freemarker.FreeMarkerView</value> </property> </bean> <bean id="jspResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" p:order="2" /> <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="defaultEncoding" value="UTF-8"/> </bean> </beans> [/code] Controller如下: [code="java"] @Controller @RequestMapping("/user") @Scope("prototype") public class UserController { @RequestMapping public String show(@RequestParam long userId,ModelMap model){ System.out.println(Config.getString("user#Test")); User u = userService.getUser(userId); System.out.println(u.getUser2().size()); model.addAttribute("u",u); return "/user/test"; } } [/code] 在WEB-INF的freemarker/user目录下有test.ftl文件,但是通过路径:http://localhost:8080/Test/user?method=show&userId=20访问的时候却不能跳到ftl模板处。 分析日志时发现有这么几句话: 2010-01-22 15:48:41,468 [http-8080-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'freemarkerConfig' 2010-01-22 15:48:41,468 [http-8080-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name '/user/test' 2010-01-22 15:48:41,468 [http-8080-1] DEBUG freemarker.cache - Could not find template in cache, creating new one; id=[WEB-INF/freemarker/user/test.ftl[zh_CN,UTF-8,parsed] ] [color=red]2010-01-22 15:48:41,500 [http-8080-1] DEBUG org.springframework.web.servlet.view.freemarker.FreeMarkerView - No FreeMarker view found for URL: /WEB-INF/freemarker/user/test.ftl[/color] 2010-01-22 15:48:41,500 [http-8080-1] DEBUG org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver - Cached view [/user/test] 2010-01-22 15:48:41,500 [http-8080-1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name '/user/test' 2010-01-22 15:48:41,500 [http-8080-1] DEBUG org.springframework.web.servlet.view.InternalResourceViewResolver - Cached view [/user/test] 非常郁闷啊,我在这个目录下确实存在模板文件啊,为什么它说不存在呢??有人知道为什么吗?

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

再不跳槽,应届毕业生拿的都比我多了!

跳槽几乎是每个人职业生涯的一部分,很多HR说“三年两跳”已经是一个跳槽频繁与否的阈值了,可为什么市面上有很多程序员不到一年就跳槽呢?他们不担心影响履历吗? PayScale之前发布的**《员工最短任期公司排行榜》中,两家码农大厂Amazon和Google**,以1年和1.1年的员工任期中位数分列第二、第四名。 PayScale:员工最短任期公司排行榜 意外的是,任期中位数极小的这两家公司,薪资...

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

数据库——玩转SQL语句(以MySQL为例)

一、前言 照着大学的SQL server来学

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

华为初面+综合面试(Java技术面)附上面试题

华为面试整体流程大致分为笔试,性格测试,面试,综合面试,回学校等结果。笔试来说,华为的难度较中等,选择题难度和网易腾讯差不多。最后的代码题,相比下来就简单很多,一共3道题目,前2题很容易就AC,题目已经记不太清楚,不过难度确实不大。最后一题最后提交的代码过了75%的样例,一直没有发现剩下的25%可能存在什么坑。 笔试部分太久远,我就不怎么回忆了。直接将面试。 面试 如果说腾讯的面试是挥金如土...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

程序员写出这样的代码,能不挨骂吗?

当你换槽填坑时,面对一个新的环境。能够快速熟练,上手实现业务需求是关键。但是,哪些因素会影响你快速上手呢?是原有代码写的不够好?还是注释写的不够好?昨夜...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

HTTP与HTTPS的区别

面试官问HTTP与HTTPS的区别,我这样回答让他竖起大拇指!

程序员毕业去大公司好还是小公司好?

虽然大公司并不是人人都能进,但我仍建议还未毕业的同学,尽力地通过校招向大公司挤,但凡挤进去,你这一生会容易很多。 大公司哪里好?没能进大公司怎么办?答案都在这里了,记得帮我点赞哦。 目录: 技术氛围 内部晋升与跳槽 啥也没学会,公司倒闭了? 不同的人脉圈,注定会有不同的结果 没能去大厂怎么办? 一、技术氛围 纵观整个程序员技术领域,哪个在行业有所名气的大牛,不是在大厂? 而且众所...

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《C语言函数速查》main()主函数

每一个C程序都必须有一main()函数, 可以根据自己的爱好把它放在程序的某个地方。有些程序员把它放在最前面, 而另一些程序员把它放在最后面, 无论放在哪个地方, 以下几点说明都是适合的。

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大牛都会用的IDEA调试技巧!!!

导读 前天面试了一个985高校的实习生,问了他平时用什么开发工具,他想也没想的说IDEA,于是我抛砖引玉的问了一下IDEA的调试用过吧,你说说怎么设置断点...

立即提问
相关内容推荐