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

图片说明图片说明

浏览器输入错误地址,给出的是spring的错误页面,没有进入我写的页面
error.ftl.而且输入http://localhost:8080,也没有进入index.ftl.

1个回答

重新部署下看看,你现在访问看到的是什么,是spring boot的错误页面还是什么错误?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
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) 我个人思考了一下,应该是配置的问题,但问题出在哪儿不知道。
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为什么会出现找到不模板的问题
Freemarker错误
<p> </p> <pre name="code" class="java">public class HelloFreeMarker { private Configuration cfg ; public void init() throws Exception { cfg = new Configuration(); cfg.setDirectoryForTemplateLoading(new File("src\\com\\s2freemarker\\exer\\templates")); } public void process() throws Exception{ Map&lt;Object,Object&gt; root = new HashMap&lt;Object,Object&gt;(); root.put("name", "FreeMarker"); root.put("msg", "First example for freemarker ."); Template t = cfg.getTemplate("test.ftl"); t.process(t, new OutputStreamWriter(System.out)); } /** * @param args */ public static void main(String[] args) throws Exception{ HelloFreeMarker hfm = new HelloFreeMarker(); hfm.init(); hfm.process(); } }</pre> <p> </p> <p>模版文件:</p> <p> </p> <pre name="code" class="ftl">${name},hello!${msg}</pre>   <p>错误提示:</p> <p> </p> <pre name="code" class="java">Aug 18, 2011 10:49:25 AM freemarker.log.JDK14LoggerFactory$JDK14Logger error SEVERE: Expression msg is undefined on line 1, column 17 in test.ftl. Expression msg is undefined on line 1, column 17 in test.ftl. The problematic instruction: ---------- ==&gt; ${msg} [on line 1, column 15 in test.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression msg is undefined on line 1, column 17 in test.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.Expression.getStringValue(Expression.java:118) 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.Environment.process(Environment.java:190) at freemarker.template.Template.process(Template.java:237) at com.s2freemarker.exer.test.HelloFreeMarker.process(HelloFreeMarker.java:30) at com.s2freemarker.exer.test.HelloFreeMarker.main(HelloFreeMarker.java:39) test.ftl,hello! Expression msg is undefined on line 1, column 17 in test.ftl. The problematic instruction: ---------- ==&gt; ${msg} [on line 1, column 15 in test.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression msg is undefined on line 1, column 17 in test.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.Expression.getStringValue(Expression.java:118) 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.Environment.process(Environment.java:190) at freemarker.template.Template.process(Template.java:237) at com.s2freemarker.exer.test.HelloFreeMarker.process(HelloFreeMarker.java:30) at com.s2freemarker.exer.test.HelloFreeMarker.main(HelloFreeMarker.java:39) Exception in thread "main" Expression msg is undefined on line 1, column 17 in test.ftl. The problematic instruction: ---------- ==&gt; ${msg} [on line 1, column 15 in test.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression msg is undefined on line 1, column 17 in test.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.Expression.getStringValue(Expression.java:118) 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.Environment.process(Environment.java:190) at freemarker.template.Template.process(Template.java:237) at com.s2freemarker.exer.test.HelloFreeMarker.process(HelloFreeMarker.java:30) at com.s2freemarker.exer.test.HelloFreeMarker.main(HelloFreeMarker.java:39) </pre>
freemarker: Template not found for name "xxx.ftl".
报错信息: ``` 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 目录结构: ![](https://static.oschina.net/uploads/space/2017/0719/174655_0DYv_2353983.png) 报错行: ``` Template template = freeMarkerConfig.getConfiguration().getTemplate(templateName); ``` 参照配置:[https://my.oschina.net/HuifengWang/blog/300461](https://my.oschina.net/HuifengWang/blog/300461)
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) 有哪个大神遇到过这样的问题么,最后是怎么解决的?
Eclipse 中添加.ftl(free market )支持如何让其报错和支持提示?
Eclipse 中添加.ftl(free market )支持如何让其报错和支持提示?
springboot启动报错org.apache.tomcat.util.net.NioEndpoint
springboot启动后就一直报这个,不影响访问,但是总觉得哪里不对,,,,,我使用的nohup java -jar -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -Xms2048m -Xmx2048m -Xmn768m -Xss256k -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=15 jiyaoNewWeb-1.0.jar >springboot.log 2>&1 & 这个命令来启动的,我使用nohup java -jar xxx&命令来启动也是这样,这个怎么解决啊?? 2019-08-26 22:42:54,609 [https-jsse-nio-443-exec-1] ERROR org.apache.tomcat.util.net.NioEndpoint - java.lang.IllegalArgumentException: null at java.nio.Buffer.position(Buffer.java:244) at org.apache.tomcat.util.net.TLSClientHelloExtractor.skipBytes(TLSClientHelloExtractor.java:221) at org.apache.tomcat.util.net.TLSClientHelloExtractor.<init>(TLSClientHelloExtractor.java:118) at org.apache.tomcat.util.net.SecureNioChannel.processSNI(SecureNioChannel.java:276) at org.apache.tomcat.util.net.SecureNioChannel.handshake(SecureNioChannel.java:174) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1436) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) 这是我的pom==> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.boot</groupId> <artifactId>jiyaoNewWeb</artifactId> <version>1.0</version> <packaging>jar</packaging> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> <relativePath/> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-core</artifactId> <version>4.0.3</version> </dependency> <dependency> <groupId>com.aliyun</groupId> <artifactId>aliyun-java-sdk-dysmsapi</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.16.20</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>com.aliyun.oss</groupId> <artifactId>aliyun-sdk-oss</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.4</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>23.0</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.10-FINAL</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-io</artifactId> <version>1.3.2</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.10</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.6</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-freemarker</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- mybatis整合 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version> </dependency> <!-- 引入thymelaf 则不需要引入web依赖,若不需要thymelaf则需要添加spring-boot-starter-web --> <!--<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>--> <!-- mysql驱动 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- 连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.12</version> </dependency> <!--<dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.10</version> </dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <!--<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>5.1.2.RELEASE</version> </dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.54</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <version>1.5.13.RELEASE</version> </dependency> <dependency> <groupId>com.taobao</groupId> <artifactId>taobao-sdk-java-auto_1554188611497</artifactId> <version>20190513</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.2</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>com.boot.SpringWebApplication</mainClass> <classpathPrefix>lib/</classpathPrefix> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project>
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)
freemarker读取bean出错
Test.java package org.test; import java.util.*; import java.io.*; import freemarker.template.*; public class Test { public static void main(String[] args) throws Exception { Configuration cfg = new Configuration(); cfg.setDirectoryForTemplateLoading(new File("E:/new")); cfg.setObjectWrapper(new DefaultObjectWrapper()); Template temp = cfg.getTemplate("test.ftl"); User user = new User(); user.setId("1"); user.setAge("88"); user.setName("ttt"); Map root = new HashMap(); root.put("user", user); Writer out = new OutputStreamWriter(System.out); temp.process(root, out); out.flush(); System.out.println("\nOK!"); } } class User { private String id; private String name; private String age; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } } test.ftl <html> <head> <title>Welcome</title> </head> <body> <h1>Welcome </h1> id:${user.id}<br> name:${user.name}<br> age:${user.age}<br> </body> </html> 错误: 2008-8-1 10:50:44 freemarker.log.JDK14LoggerFactory$JDK14Logger error 严重: Expression user.id is undefined on line 7, column 6 in test.ftl. The problematic instruction: ---------- ==> ${user.id} [on line 7, column 4 in test.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression user.id is undefined on line 7, column 6 in test.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.Expression.getStringValue(Expression.java:118) 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.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 org.test.Test.main(Test.java:23) Exception in thread "main" Expression user.id is undefined on line 7, column 6 in test.ftl. The problematic instruction: ---------- ==> ${user.id} [on line 7, column 4 in test.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.InvalidReferenceException: Expression user.id is undefined on line 7, column 6 in test.ftl. at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124) at freemarker.core.Expression.getStringValue(Expression.java:118) 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.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 org.test.Test.main(Test.java:23)
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)
SpringBoot+FreeMarker 国际化这么切换语言?
国际化参考网上的搞好了,但是配置好之后,默认中文,怎么切换英文? ![图片说明](https://img-ask.csdn.net/upload/201809/30/1538277501_822404.png) ![图片说明](https://img-ask.csdn.net/upload/201809/30/1538277513_617159.png) 页面引用 ``` 这个默认是中文 <@spring.message code="welcome"/> 向页面输出国际化信息 下面这个加上去报错 <@spring.message code="welcome?lang=en_US"/> 向页面输出国际化信息 ```
请问FreeMarket 能不能在页面上直接点出对象的集合或数组的字段
遇到一个问题不知道怎么直接点对象点的集合或数组的字段 public class CalenderCell { private Collection performIds; private String smallPic; //getter/setter方法略^-^ } 下面是报错的部分 [color=red]<input type"hidden" id="plays${x}" value="${cells[x - firstDate].performIds}">[/color] 报下面的错误 2009-01-19 10:50:36,468 ERROR [freemarker.runtime] - <> Error on line 39, column 85 in movieCalendar.ftl Expecting a string, date or number here, Expression cells[x - firstDate].performIds is instead a freemarker.template.SimpleSequence The problematic instruction: ---------- ==> ${cells[x - firstDate].performIds} [on line 39, column 83 in movieCalendar.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.NonStringException: Error on line 39, column 85 in movieCalendar.ftl Expecting a string, date or number here, Expression cells[x - firstDate].performIds is instead a freemarker.template.SimpleSequence at freemarker.core.Expression.getStringValue(Expression.java:126) 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.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:208) at freemarker.core.IfBlock.accept(IfBlock.java:82) 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.IteratorBlock$Context.runLoop(IteratorBlock.java:179) at freemarker.core.Environment.visit(Environment.java:415) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102) 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:232) at com.uchacha.core.movieCalendar.template.FMWriter.process(FMWriter.java:60) at com.uchacha.core.movieCalendar.template.FMWriter.write(FMWriter.java:43) at com.uchacha.core.movieCalendar.template.CalanderWriter.main(CalanderWriter.java:98) Error on line 39, column 85 in movieCalendar.ftl Expecting a string, date or number here, Expression cells[x - firstDate].performIds is instead a freemarker.template.SimpleSequence The problematic instruction: ---------- ==> ${cells[x - firstDate].performIds} [on line 39, column 83 in movieCalendar.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.NonStringException: Error on line 39, column 85 in movieCalendar.ftl Expecting a string, date or number here, Expression cells[x - firstDate].performIds is instead a freemarker.template.SimpleSequence at freemarker.core.Expression.getStringValue(Expression.java:126) 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.MixedContent.accept(MixedContent.java:92) at freemarker.core.Environment.visit(Environment.java:208) at freemarker.core.IfBlock.accept(IfBlock.java:82) 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.IteratorBlock$Context.runLoop(IteratorBlock.java:179) at freemarker.core.Environment.visit(Environment.java:415) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:102) 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:232) at com.uchacha.core.movieCalendar.template.FMWriter.process(FMWriter.java:60) at com.uchacha.core.movieCalendar.template.FMWriter.write(FMWriter.java:43) at com.uchacha.core.movieCalendar.template.CalanderWriter.main(CalanderWriter.java:98) 请问有没有遇到过类似的问题并怎么解决的啊?
springboot freemarker不渲染页面返回字符串
前台: ![图片说明](https://img-ask.csdn.net/upload/201911/30/1575085795_158966.png) 后台: ![图片说明](https://img-ask.csdn.net/upload/201911/30/1575085847_908964.png) 使用modelView 返回的是页面的字符串,不是页面,这个怎么弄呢
thymeleaf用th:text不能获取到model的值,提示为null
thymeleaf用th:text不能获取到model的值,提示为null; freemarker也是提示为null; 但能取session的值,th标签遍历也不能遍历,json都能正常显示没问题。 ## **controller** ![图片说明](https://img-ask.csdn.net/upload/202001/10/1578625487_609690.png) ## **html** ![图片说明](https://img-ask.csdn.net/upload/202001/10/1578625518_456.png) ## **配置** ``` thymeleaf: cache: false checktemplatelocation: true enabled: true encoding: UTF-8 mode: HTML5 prefix: classpath:/templates/ suffix: .html ```
用springboot+freemarker+mybatis写一个登录和注册,和找回密码的界面
这是数据库的代码 create table `tb_user` ( `user_id` int(100) not null auto_increment comment'用户表id', `user_name` varchar(200) not null comment'用户名', `user_password` varchar(1000)not null comment'用户密码', `user_phone` varchar(1000) not null, `user_type`int(10)not null comment'用户类型', `user_email`varchar(2000) default null, `user_quesion`varchar(2000)default null comment'找回密码问题', `user_answer`varchar(2000)default null comment'找回密码答案', `create_time` datetime default null comment'创建时间', `last_edit_time` datetime default null comment'更新时间', primary key(`user_id`), unique key `user_name_unique`(`user_name`)using btree ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
freemarker0.9.14,myeclipse2017 装完打开ftl文件就报错
![图片说明](https://img-ask.csdn.net/upload/201703/17/1489717646_556799.jpg) hudson.freemarker_ide_0.9.14,myeclipse2017 装完打开ftl文件就报错 求解决,商店下载的就2种颜色,h5元素完全是黑的,不好用。或者有什么好用的插件吗?推荐下
将html转换成freemarker中的ftl模板
将html转换成freemarker中的ftl模板,求代码,求模板
springboot freemarker 国际化只显示中文,点击英文切换不起作用?
为什么我这个国际化,点击切换按钮英文不起作用?只显示中文 ![图片说明](https://img-ask.csdn.net/upload/201908/06/1565083505_319808.png) ![图片说明](https://img-ask.csdn.net/upload/201908/06/1565083514_850314.png) ![图片说明](https://img-ask.csdn.net/upload/201908/06/1565083520_252705.png) ![图片说明](https://img-ask.csdn.net/upload/201908/06/1565083527_545657.png) 最后附上controller代码 ``` package com.yadu.example.demo.controller; import com.yadu.example.demo.entity.User; import com.yadu.example.demo.service.LocaleMessageSourceService; import com.yadu.example.demo.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.MessageSource; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import javax.annotation.Resource; @RestController public class Controller { @Autowired private UserService userService; @Autowired private MessageSource messageSource; /** * 获取国际化信息 */ @Resource private LocaleMessageSourceService localeMessageSourceService; @GetMapping("/hi") public String index(){ return "hello spring boot"; } @RequestMapping("/users/{userId}") public User getUser(@PathVariable("userId") int userId){ User user = userService.getById(userId); return user; } /** * freemarker模板 * @param modelAndView * @return */ @RequestMapping(value = "/indexFre") public ModelAndView indexFre(ModelAndView modelAndView) { //设置返回的页面名称 modelAndView.setViewName("indexFre"); //要返回在页面的数据 /* List<User> userList = userService.getUsers(); modelAndView.addObject("userList", userList);*/ return modelAndView; } @RequestMapping("/hello") public ModelAndView hello(ModelAndView modelAndView){ String msg3 = localeMessageSourceService.getMessage("welcome"); modelAndView.setViewName("hello"); return modelAndView; } /* @RequestMapping("/changeSessionLanauage") public String changeSessionLanauage(HttpServletRequest request, HttpServletResponse response, String lang){ System.out.println(lang); LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); if("zh".equals(lang)){ localeResolver.setLocale(request, response, new Locale("zh", "CN")); }else if("en".equals(lang)){ localeResolver.setLocale(request, response, new Locale("en", "US")); } return "redirect:/hello"; }*/ } ```
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没解析出来? 希望有知道的高手帮忙解答,本人不胜感激!
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载 点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。 ...
字节跳动视频编解码面经
三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时想着能进去就不错了,管他哪个岗呢,就同意了面试...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
Python 基础(一):入门必备知识
Python 入门必备知识,你都掌握了吗?
兼职程序员一般可以从什么平台接私活?
这个问题我进行了系统性的总结,以下将进行言简意赅的说明和渠道提供,希望对各位小猿/小媛们有帮助~ 根据我们的经验,程序员兼职主要分为三种:兼职职位众包、项目整包和自由职业者驻场。 所谓的兼职职位众包,指的是需求方这边有自有工程师配合,只需要某个职位的工程师开发某个模块的项目。比如开发一个 app,后端接口有人开发,但是缺少 iOS 前端开发工程师,那么他们就会发布一个职位招聘前端,来配合公司一...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
写了很久,这是一份最适合/贴切普通大众/科班/非科班的『学习路线』
说实话,对于学习路线这种文章我一般是不写的,大家看我的文章也知道,我是很少写建议别人怎么样怎么样的文章,更多的是,写自己的真实经历,然后供大家去参考,这样子,我内心也比较踏实,也不怕误导他人。 但是,最近好多人问我学习路线,而且很多大一大二的,说自己很迷茫,看到我那篇 普普通通,我的三年大学 之后很受激励,觉得自己也能行,(是的,别太浪,你一定能行)希望我能给他个学习路线,说...
经典算法(5)杨辉三角
写在前面: 我是 扬帆向海,这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录,如果您对 Java、算法 感兴趣,可以关注我的动态,我们一起学习。 用知识改变命运,让我们的家人过上更好的生活。 目录一、杨辉三角的介绍二、杨辉三角的算法思想三、代码实现1.第一种写法2.第二种写法 一、杨辉三角的介绍 百度
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,
程序员:我终于知道post和get的区别
IT界知名的程序员曾说:对于那些月薪三万以下,自称IT工程师的码农们,其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居,但只是他们一厢情愿罢了。 此话一出,不知激起了多少(码农)程序员的愤怒,却又无可奈何,于是码农问程序员。 码农:你知道get和post请求到底有什么区别? 程序员:你看这篇就知道了。 码农:你月薪三万了? 程序员:嗯。 码农:你是怎么做到的? 程序员:
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI 算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
面试官如何考察你的思维方式?
1.两种思维方式在求职面试中,经常会考察这种问题:北京有多少量特斯拉汽车? 某胡同口的煎饼摊一年能卖出多少个煎饼? 深圳有多少个产品经理? 一辆公交车里能装下多少个乒乓球? 一
碎片化的时代,如何学习
今天周末,和大家聊聊学习这件事情。 在如今这个社会,我们的时间被各类 APP 撕的粉碎。 刷知乎、刷微博、刷朋友圈; 看论坛、看博客、看公号; 等等形形色色的信息和知识获取方式一个都不错过。 貌似学了很多,但是却感觉没什么用。 要解决上面这些问题,首先要分清楚一点,什么是信息,什么是知识。 那什么是信息呢? 你一切听到的、看到的,都是信息,比如微博上的明星出轨、微信中的表情大战、抖音上的...
so easy! 10行代码写个"狗屁不通"文章生成器
前几天,GitHub 有个开源项目特别火,只要输入标题就可以生成一篇长长的文章。 背后实现代码一定很复杂吧,里面一定有很多高深莫测的机器学习等复杂算法 不过,当我看了源代码之后 这程序不到50行 尽管我有多年的Python经验,但我竟然一时也没有看懂 当然啦,原作者也说了,这个代码也是在无聊中诞生的,平时撸码是不写中文变量名的, 中文...
知乎高赞:中国有什么拿得出手的开源软件产品?(整理自本人原创回答)
知乎高赞:中国有什么拿得出手的开源软件产品? 在知乎上,有个问题问“中国有什么拿得出手的开源软件产品(在 GitHub 等社区受欢迎度较好的)?” 事实上,还不少呢~ 本人于2019.7.6进行了较为全面的回答,对这些受欢迎的 Github 开源项目分类整理如下: 分布式计算、云平台相关工具类 1.SkyWalking,作者吴晟、刘浩杨 等等 仓库地址: apache/skywalking 更...
相关热词 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片 c# 图片颜色调整 最快 c#多张图片上传 c#密封类与密封方法
立即提问

相似问题

2
springmvc 注解方式配置时,没有了web.xml,如何内嵌jetty
2
main函数创建Configuration() 没有问题,在controller上执行就报错
0
freemarker导出word 图片显示异常
1
使用freemarker生成的xml格式word文档,如何转成标准格式的word?
3
springboot启动失败,报端口被占用
1
springboot 配置多库之后,mybatis在控制台不打印sql语句了
2
Springboot突然无法加载模板文件了,返回字符串就不会报错。那个大神帮小弟看看
1
用freemarker生成word文档,然后我先继续用java操作这个文档,对姓名之类的字段进行操作,有什么办法?
3
Java中使用freemarker导出word文档 循环生成表格并且表格每行中都自动插入图片
3
freemarker 怎么判断对象为空(注意是为空,?? 这个是判断不为空)
5
freemarker生成了word 如何转换PDF
0
freeMarker模板中的buildNode是什么作用?
1
springboot freemarker 国际化只显示中文,点击英文切换不起作用?
1
Java使用freemarker生成word文档,怎么设置动态的生成文档路径?
2
springboot启动报错org.apache.tomcat.util.net.NioEndpoint
1
IDEA webSpringMVC项目整合Freemarker时返回视图名必须以.ftl后缀结尾
0
springboot+jdbc+dm无法创建池的初始连接
1
使用freemarker工具导出word,windows中没问题,Linux中下载后发现word打不开,最后一行多了{}符号,怎么处理。
1
FreeMarker For "?c" left-hand operand: Expected a number or boolean, but this evaluated to a string (wrapper: f.t.SimpleScalar) 不明白这个错和我的写法有什么关系?
1
freemarker前端如何遍历数据库中的数据