把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]

4个回答

首先分析需求,是否应用需要经常修改ftl。

如果是,建议不要打入jar,放到WEB-INF/classes里好了。

如果不是, ant build做两套 :
一套开发的,ftl文件放外面
一套最终发布的,ftl打入jar。

因为freemarker有缓存,放入jar的不能监视文件是否被修改,所以
没办法更新。

你打包时候应该把ftl的模板文件放在jar包外面,而不是一起打包进去。

每次都这样吗,还是只是有时,如果每次的话怀疑是tomcat的reload方式的问题导致

你这么做吧,你把ftl文件单独打包成jar,命名resources.jar,有些开源项目就是把资源单独打包的,你这样试看看还会不会有这个问题

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
悬赏20:给java.class文件添加一个可以随时修改参数的前端
package service; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Properties; import servlet.FreeMarkServlet; import sun.misc.BASE64Encoder; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; /** * 使用freemark生成word * @author stormwy */ public class Freemark { public static void main(String[] args){ Freemark freemark = new Freemark("/template"); // freemark.setTemplateName("wordTemplate.ftl"); freemark.setTemplateName("word1.ftl"); freemark.setFileName("word6"+".docx"); freemark.setFilePath("WebContent/resources/"); freemark.createWord(); } public void createWord(){ Template t = null; try { t = configuration.getTemplate(templateName); } catch (IOException e) { e.printStackTrace(); } File outFile = new File(filePath+fileName); Writer out = null; try { out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } // FreeMarkServlet pro = new FreeMarkServlet(); Map<String, Object> map = new HashMap<String, Object>(); map.put("date1", bianxieren); map.put("date2", shenpiren); map.put("date3", bianxie); map.put("date4", shenpi); /* map.put("image", getImageStr()); map.put("SEX", "男"); map.put("BIRTH", "1987-08"); map.put("ZZMM", "党员"); */ try { t.process(map, out); out.close(); } catch (TemplateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } /** * freemark初始化 * @param templatePath 模板文件位置 */ public Freemark(String templatePath) { configuration = new Configuration(); configuration.setDefaultEncoding("utf-8"); configuration.setClassForTemplateLoading(this.getClass(),templatePath); } //插入图片 /*private String getImageStr() { String imgFile = "D:/hanmanyi/pic/111.jpg"; InputStream in = null; byte[] data = null; try { in = new FileInputStream(imgFile); data = new byte[in.available()]; in.read(data); in.close(); } catch (IOException e) { e.printStackTrace(); } BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(data); }*/ /** * freemark模板配置 */ private Configuration configuration; /** * freemark模板的名字 */ private String templateName; /** * 生成文件名 */ private String fileName; /** * 生成文件路径 */ private String filePath; public String getFileName() { return fileName; } public void setFileName(String fileName) { this.fileName = fileName; } public String getFilePath() { return filePath; } public void setFilePath(String filePath) { this.filePath = filePath; } public String getTemplateName() { return templateName; } public void setTemplateName(String templateName) { this.templateName = templateName; } } ![图片说明](https://img-ask.csdn.net/upload/201805/03/1525316592_104858.png)这块是要修改的参数 那个freeMark是一个自己可以运行的的文件,他的功能是可以修改一部分参数,生成一个word文档,但是修改参数的时候必须在文件里修改,所以我就想能不能通过页面输入值给它修改 我自己弄个了简单的前台,我想用前台把值传给这个freeMark,请教了别人,说需要通过servlet,我吧值能传给servlet,但是死活不会从servlet吧值传给freeMark.java了
freemarker 模板刷新freemarker
freemarker 模板刷新freemarker 模板刷新freemarker 模板刷新freemarker 模板刷新freemarker 模板刷新freemarker 模板刷新
在linux中执行java.jar时报错
[devafs:/home/devafs/batch/sbin] sh start.sh Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file) where options include: -d32 use a 32-bit data model if available -d64 use a 64-bit data model if available -client to select the "client" VM -server to select the "server" VM -hotspot is a synonym for the "client" VM [deprecated] The default VM is server, because you are running on a server-class machine. -cp <class search path of directories and zip/jar files> -classpath <class search path of directories and zip/jar files> A : separated list of directories, JAR archives, and ZIP archives to search for class files. -D<name>=<value> set a system property -verbose[:class|gc|jni] enable verbose output -version print product version and exit -version:<value> require the specified version to run -showversion print product version and continue -jre-restrict-search | -jre-no-restrict-search include/exclude user private JREs in the version search -? -help print this help message -X print help on non-standard options -ea[:<packagename>...|:<classname>] -enableassertions[:<packagename>...|:<classname>] enable assertions -da[:<packagename>...|:<classname>] -disableassertions[:<packagename>...|:<classname>] disable assertions -esa | -enablesystemassertions enable system assertions -dsa | -disablesystemassertions disable system assertions -agentlib:<libname>[=<options>] load native agent library <libname>, e.g. -agentlib:hprof see also, -agentlib:jdwp=help and -agentlib:hprof=help -agentpath:<pathname>[=<options>] load native agent library by full pathname -javaagent:<jarpath>[=<options>] load Java programming language agent, see java.lang.instrument -splash:<imagepath> show splash screen with specified image invalid file (bad magic number): Exec format error invalid file (bad magic number): Exec format error invalid file (bad magic number): Exec format error invalid file (bad magic number): Exec format error invalid file (bad magic number): Exec format error Failed to load Main-Class manifest attribute from /home/devafs/batch/lib/db2jcc.jar start.sh #!/bin/sh export args="" while [ $# -ne 0 ] do export args="$args""$1 " shift done java -Xms512M -Xmx512M -Dfile.encoding=GBK -classpath ../lib/c3p0-0.9.1.2.jar;../lib/commons-beanutils-1.8.0.jar;../lib/commons-digester-2.0.jar;../lib/commons-io-1.4.jar;../lib/commons-lang-2.5.jar;../lib/commons-logging-1.1.1.jar;../lib/db2jcc.jar;../lib/freemarker-2.3.8.jar;../lib/junit-4.8.1.jar;../lib/log4j-1.2.16.jar;../lib/slf4j-api-1.6.1.jar;../lib/slf4j-log4j12-1.6.1.jar;../lib/spring-asm-3.0.4.RELEASE.jar;../lib/spring-core-3.0.4.RELEASE.jar;../lib/topbatch-1.2.jar com.huateng.topafs.frame.BatchRunner $args 描述:代码在doc界面中执行成功,但是在linux下执行则报此错误,请知道的朋友指点。
关于struts2.5.5的环境搭建问题
最近开始学习struts2,在官网下载了struts2.all.zip之后,然后创建一个web项目,对web.xml进行了配置,filter-class我写的是org.Apache.struts2.dispatcher.ng.filter.StrutsPrepearAndExecuteFilter,url-pattern是/*。下面导入jar包,我在lib目录下把这些jar包复制到了工程的lib目录下: struts2-core-2.5.5.jar ognl-2.7.3.jar freemarker-2.3.23.jar commons-logging-1.1.3.jar commons-lang-2.4.jar commons-io-2.4.jar commons-fileupload-1.3.2.jar javassist-3.20.0-GA.jar 运行之后报出java.lang.ClassNotFoundException
做freemarker练习,用测试类测试成功了,转到页面就报错了?
用测试类测试的时候都找到了,完全能实现功能,换成用servlet就报错 java.io.FileNotFoundException: Templates does not exist. 求大神指点这是什么情况
我用自己maven打的jar包里面的工具包报OGNL错误
错误位置代码: ``` Object o = session.get(Constants.MANAGER_USER); ``` 使用Constants的时候出现错误,急求啊! 错误如下: ``` Key "location" was not found on instance of ognl.MethodFailedException. Introspection information for the class is: {reason=java.beans.PropertyDescriptor[name=reason; propertyType=class java.lang.Throwable; readMethod=public java.lang.Throwable ognl.OgnlException.getReason()], getClass=public final native java.lang.Class java.lang.Object.getClass(), getLocalizedMessage=public java.lang.String java.lang.Throwable.getLocalizedMessage(), cause=java.beans.PropertyDescriptor[name=cause; propertyType=class java.lang.Throwable; readMethod=public synchronized java.lang.Throwable java.lang.Throwable.getCause()], java.lang.Object@20f2097b={public ognl.Evaluation ognl.OgnlException.getEvaluation()=[Ljava.lang.Class;@351d3546, public java.lang.String java.lang.Throwable.getLocalizedMessage()=[Ljava.lang.Class;@2e8d3d8f, public java.lang.String ognl.OgnlException.toString()=[Ljava.lang.Class;@253d3df4, public synchronized java.lang.Throwable java.lang.Throwable.initCause(java.lang.Throwable)=[Ljava.lang.Class;@376d7802, public java.lang.String java.lang.Throwable.getMessage()=[Ljava.lang.Class;@6b06ccac, public native int java.lang.Object.hashCode()=[Ljava.lang.Class;@2c20f506, public boolean java.lang.Object.equals(java.lang.Object)=[Ljava.lang.Class;@603eafeb, public synchronized java.lang.Throwable java.lang.Throwable.getCause()=[Ljava.lang.Class;@3ccf6686, public void ognl.OgnlException.setEvaluation(ognl.Evaluation)=[Ljava.lang.Class;@6171ae1f, public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[])=[Ljava.lang.Class;@4a52fff2, public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()=[Ljava.lang.Class;@5f8640a4, public final synchronized void java.lang.Throwable.addSuppressed(java.lang.Throwable)=[Ljava.lang.Class;@183af684, public final synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed()=[Ljava.lang.Class;@7457b2ca, public java.lang.Throwable ognl.OgnlException.getReason()=[Ljava.lang.Class;@29276edd, public final native java.lang.Class java.lang.Object.getClass()=[Ljava.lang.Class;@4449883d, public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace()=[Ljava.lang.Class;@b88c8e6}, getCause=public synchronized java.lang.Throwable java.lang.Throwable.getCause(), evaluation=java.beans.PropertyDescriptor[name=evaluation; propertyType=class ognl.Evaluation; readMethod=public ognl.Evaluation ognl.OgnlException.getEvaluation()], getStackTrace=public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace(), addSuppressed=public final synchronized void java.lang.Throwable.addSuppressed(java.lang.Throwable), hashCode=public native int java.lang.Object.hashCode(), getSuppressed=public final synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed(), suppressed=java.beans.PropertyDescriptor[name=suppressed; propertyType=class [Ljava.lang.Throwable;; readMethod=public final synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed()], stackTrace=java.beans.PropertyDescriptor[name=stackTrace; propertyType=class [Ljava.lang.StackTraceElement;; readMethod=public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()], class=java.beans.PropertyDescriptor[name=class; propertyType=class java.lang.Class; readMethod=public final native java.lang.Class java.lang.Object.getClass()], getEvaluation=public ognl.Evaluation ognl.OgnlException.getEvaluation(), localizedMessage=java.beans.PropertyDescriptor[name=localizedMessage; propertyType=class java.lang.String; readMethod=public java.lang.String java.lang.Throwable.getLocalizedMessage()], printStackTrace=freemarker.ext.beans.OverloadedMethods@4200fabf, java.lang.Object@71ff185a=freemarker.ext.beans.OverloadedMethods@504335a4, getReason=public java.lang.Throwable ognl.OgnlException.getReason(), initCause=public synchronized java.lang.Throwable java.lang.Throwable.initCause(java.lang.Throwable), getMessage=public java.lang.String java.lang.Throwable.getMessage(), message=java.beans.PropertyDescriptor[name=message; propertyType=class java.lang.String; readMethod=public java.lang.String java.lang.Throwable.getMessage()], setEvaluation=public void ognl.OgnlException.setEvaluation(ognl.Evaluation), setStackTrace=public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[]), equals=public boolean java.lang.Object.equals(java.lang.Object), toString=public java.lang.String ognl.OgnlException.toString(), fillInStackTrace=public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace()} 2017-07-09 12:02:15,839 [http-apr-8080-exec-6] DEBUG [freemarker.beans] - Key "location" was not found on instance of java.lang.NoSuchFieldError. Introspection information for the class is: {getClass=public final native java.lang.Class java.lang.Object.getClass(), localizedMessage=java.beans.PropertyDescriptor[name=localizedMessage; propertyType=class java.lang.String; readMethod=public java.lang.String java.lang.Throwable.getLocalizedMessage()], printStackTrace=freemarker.ext.beans.OverloadedMethods@419b5593, getLocalizedMessage=public java.lang.String java.lang.Throwable.getLocalizedMessage(), java.lang.Object@71ff185a=freemarker.ext.beans.OverloadedMethods@556c0a17, initCause=public synchronized java.lang.Throwable java.lang.Throwable.initCause(java.lang.Throwable), cause=java.beans.PropertyDescriptor[name=cause; propertyType=class java.lang.Throwable; readMethod=public synchronized java.lang.Throwable java.lang.Throwable.getCause()], java.lang.Object@20f2097b={public java.lang.String java.lang.Throwable.getLocalizedMessage()=[Ljava.lang.Class;@45a9bb16, public synchronized java.lang.Throwable java.lang.Throwable.initCause(java.lang.Throwable)=[Ljava.lang.Class;@72b70fee, public java.lang.String java.lang.Throwable.getMessage()=[Ljava.lang.Class;@691bebe6, public native int java.lang.Object.hashCode()=[Ljava.lang.Class;@5c926860, public boolean java.lang.Object.equals(java.lang.Object)=[Ljava.lang.Class;@546b09ef, public synchronized java.lang.Throwable java.lang.Throwable.getCause()=[Ljava.lang.Class;@1ee9b4f3, public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[])=[Ljava.lang.Class;@281b2813, public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()=[Ljava.lang.Class;@67858418, public final synchronized void java.lang.Throwable.addSuppressed(java.lang.Throwable)=[Ljava.lang.Class;@6badcd76, public java.lang.String java.lang.Throwable.toString()=[Ljava.lang.Class;@38b0b2dc, public final synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed()=[Ljava.lang.Class;@499a4e69, public final native java.lang.Class java.lang.Object.getClass()=[Ljava.lang.Class;@2f4b606, public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace()=[Ljava.lang.Class;@7b70d53}, getMessage=public java.lang.String java.lang.Throwable.getMessage(), message=java.beans.PropertyDescriptor[name=message; propertyType=class java.lang.String; readMethod=public java.lang.String java.lang.Throwable.getMessage()], getCause=public synchronized java.lang.Throwable java.lang.Throwable.getCause(), setStackTrace=public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[]), getStackTrace=public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace(), addSuppressed=public final synchronized void java.lang.Throwable.addSuppressed(java.lang.Throwable), hashCode=public native int java.lang.Object.hashCode(), equals=public boolean java.lang.Object.equals(java.lang.Object), toString=public java.lang.String java.lang.Throwable.toString(), getSuppressed=public final synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed(), suppressed=java.beans.PropertyDescriptor[name=suppressed; propertyType=class [Ljava.lang.Throwable;; readMethod=public final synchronized java.lang.Throwable[] java.lang.Throwable.getSuppressed()], stackTrace=java.beans.PropertyDescriptor[name=stackTrace; propertyType=class [Ljava.lang.StackTraceElement;; readMethod=public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()], class=java.beans.PropertyDescriptor[name=class; propertyType=class java.lang.Class; readMethod=public final native java.lang.Class java.lang.Object.getClass()], fillInStackTrace=public synchronized java.lang.Throwable java.lang.Throwable.fillInStackTrace()} ```
freemarker生成模板在windows下正常运行而在linux下报错数组越界
我需要使用freemarker生成html文件,在windows系统下能够正常运行,但是在linux系统下报错数组越界。 下面是代码: ``` public boolean generateHotArticleFreeMarker(PageData pd) throws Exception { Configuration configuration = freeMarkerConfigurer.getConfiguration(); Template template = configuration.getTemplate("hotarticle.ftl"); PageData map = new PageData(); Result result = hotArticleService.getHotArticleList(pd); map.put("totalPage", result.getTotalPage()); map.put("currentPage", result.getCurrentPage()); map.put("rows", result.getRows().size() > 0 ? result.getRows() : ""); List<TbCategory> categoryList = categoryService.getCategoryList(); map.put("categoryList", categoryList); map.put("resultPd", pd); FileWriter out = new FileWriter(new File(FREEMARKER_PATH + pd.getString("id") + ".html")); template.process(map, out); out.close(); return true; } ``` 在执行到template.process(map, out);这一行时候报错: ``` java.lang.ArrayIndexOutOfBoundsException: 415315061 at java.util.HashMap.putForCreate(HashMap.java:541) at java.util.HashMap.putAllForCreate(HashMap.java:555) at java.util.HashMap.clone(HashMap.java:796) at freemarker.template.SimpleHash.copyMap(SimpleHash.java:153) at freemarker.template.SimpleHash.<init>(SimpleHash.java:133) at freemarker.template.DefaultObjectWrapper.wrap(DefaultObjectWrapper.java:230) at freemarker.template.Template.createProcessingEnvironment(Template.java:475) at freemarker.template.Template.process(Template.java:382) at com.goodlymoon.portal.service.freemarker.HtmlFreeMarker.generateHotArticleFreeMarker(HtmlFreeMarker.java:94) at com.goodlymoon.portal.service.impl.HotArticleServiceImpl.saveHotArticle(HotArticleServiceImpl.java:98) at com.goodlymoon.portal.service.impl.HotArticleServiceImpl.getWinXinHotArticle(HotArticleServiceImpl.java:155) at com.goodlymoon.portal.service.impl.HotArticleServiceImpl$$FastClassBySpringCGLIB$$19625a23.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) at com.goodlymoon.portal.service.impl.HotArticleServiceImpl$$EnhancerBySpringCGLIB$$7c74333.getWinXinHotArticle(<generated>) at com.goodlymoon.portal.service.timer.QuartzTask$HotArticleTask.run(QuartzTask.java:97) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) ``` 有没有大神帮忙看看有什么好的解决办法吗? 我觉得路径是没有问题的,因为在指定的文件夹下生成了文件,只是没有写入内容,附图片 ![图片说明](https://img-ask.csdn.net/upload/201801/25/1516846923_953865.png)
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)
写java代码时要使用freemarker下载一个word的xml文件,结果报错
严重: Servlet.service() for servlet [springDispatcherServlet] in context with path [/frload] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.io.File]: No default constructor found; nested exception is java.lang.NoSuchMethodException: java.io.File.<init>()] with root cause java.lang.NoSuchMethodException: java.io.File.<init>() at java.lang.Class.getConstructor0(Class.java:2810) at java.lang.Class.getDeclaredConstructor(Class.java:2053) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:102) at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.createAttribute(ModelAttributeMethodProcessor.java:141) at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.createAttribute(ServletModelAttributeMethodProcessor.java:81) at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:101) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:158) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) 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:967) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) at javax.servlet.http.HttpServlet.service(HttpServlet.java:650) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:744)
用 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)
springboot启动失败,报端口被占用
在本地启动时没有问题!上服务器(阿里的centos)后,启动后报错: java.io.FileNotFoundException: class path resource [templates/] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/root/java/jiyaoNewWeb-1.0.jar!/BOOT-INF/classes!/templates/ at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:215) at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:53) at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.getTemplateLoaderForPath(FreeMarkerConfigurationFactory.java:338) at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.createConfiguration(FreeMarkerConfigurationFactory.java:290) at org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer.afterPropertiesSet(FreeMarkerConfigurer.java:116) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.boot.SpringWebApplication.main(SpringWebApplication.java:25) 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:483) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) 报这个问题之后,又继续跑了一段:最后告诉我说启动失败,说443可能被占用,我用lsof -i:看了没有在用的,现在也用的是root账号,端口也是开放了的:最后的报错信息是: 2019-04-29 15:50:33,891 [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception org.springframework.boot.context.embedded.tomcat.ConnectorStartFailedException: Connector configured to listen on port 443 failed to start
研究struts2源码时启动服务器报错
错误信息: com.opensymphony.xwork2.util.logging.commons.CommonsLogger error 严重: Dispatcher initialization failed Unable to load configuration. - Class: java.net.URL File: URL.java Method: <init> Line: 601 - java/net/URL.java:601:-1 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390) at ..... 引用: asm-3.3.1.jar commons-lang-2.6-javadoc.jar commons-lang-2.6-sources.jar commons-lang-2.6.jar velocity-1.5.jar velocity-1.6.2-dep.jar velocity-tools-1.3.jar commons-logging-api-1.1.jar commons-fileupload.jar commons-io.jar freemarker-2.3.15.jar ognl-3.0.4.jar asm-commons-3.1.jar spring.jar testng-5.8-jdk15.jar src下面除了struts2的源码外,还有 struts-default.xml struts.xml struts-default.xml是从别的项目中copy来的 struts.xml
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)
java+freemarker模板可视化编辑功能
想结合freemarker和java做一个模板可视化编辑的Demo,求高手大神解答。
Json问题,小弟很是伤心!!
我把Json及它的支持包放进项目lib目录下后,只要new了Json对象就报这个鬼错误: Method public java.lang.String org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on net.sf.json.JSONException: java.lang.reflect.InvocationTargetException freemarker.template.TemplateModelException: Method public java.lang.String org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on net.sf.json.JSONException: java.lang.reflect.InvocationTargetException at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:130) at freemarker.ext.beans.SimpleMethodModel.get(SimpleMethodModel.java:138) .................. Caused by: java.lang.NullPointerException at freemarker.ext.beans.SimpleMemberModel.unwrapArguments(SimpleMemberModel.java:85) at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:106) ... 71 more 真不知道该如何解决,, :cry: (全部家当放上去了,25分..)
修改struts2 2.3.32版本后,导致依赖注入的对象为null
添加的:struts2-core-2.3.32.jar,struts2-json-plugin-2.3.32.jar,xwork-core-2.3.32.jar,struts2-spring-plugin-2.3.32.jar 添加commons-lang3-3.2.jar,commons-lang-2.4.jar,添加javassist-3.11.0.GA.jar,commons-fileupload-1.3.2.jar,commons-io-2.2.jar,ognl-3.0.19.jar ,freemarker-2.3.22.jar,asm-3.3.1.jar,asm-common-3.3.jar,asm-tree-3.3.jar
使用了 FreeMarker+FTL模版导出word, 再通过 poi 将word转HTML会报错
FreeMarker导出的word能正常打开,就是 poi 转word 会报错。 这个问题在网上找了挺多资料的,基本上使用poi 的都是转excel 时报错的, 自己试验过,得出: 一般 的word是能被 poi 转 HTML, FreeMarker导出的word却不能poi 转 HTML 有以下报错 ``` java.io.IOException: Invalid header signature; read 0x6576206C6D783F3C, expected 0xE11AB1A1E011CFD0 at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:140) at org.apache.poi.poifs.storage.HeaderBlock.<init>(HeaderBlock.java:104) at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:138) at org.apache.poi.hwpf.HWPFDocumentCore.verifyAndBuildPOIFS(HWPFDocumentCore.java:106) at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:174) at com.dayuan.util.PoiWordToHtml.creadHTML(PoiWordToHtml.java:35) at com.dayuan.controller.sampling.SamplingController.exportSimpleWord(SamplingController.java:263) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 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 com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) 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:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 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:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:475) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:498) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1366) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) ``` 求大神支招
Myeclipse Web工程启动报错
``` 2015-12-14 10:38:51 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2882) at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:100) at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390) at java.lang.StringBuffer.append(StringBuffer.java:224) at java.io.StringWriter.write(StringWriter.java:95) at java.io.PrintWriter.write(PrintWriter.java:412) at java.io.PrintWriter.write(PrintWriter.java:429) at java.io.PrintWriter.print(PrintWriter.java:559) at java.io.PrintWriter.println(PrintWriter.java:695) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:538) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) at java.lang.Throwable.printStackTraceAsCause(Throwable.java:545) 2015-12-14 10:38:51 org.apache.catalina.core.StandardContext start 严重: Error listenerStart 2015-12-14 10:38:51 org.apache.catalina.core.StandardContext start 严重: Context [/AutoMonitor] startup failed due to previous errors 2015-12-14 10:38:51 org.apache.catalina.core.ApplicationContext log 信息: Closing Spring root WebApplicationContext 2015-12-14 10:38:53 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext (0 ms) [main] WARN : com.mchange.v2.c3p0.management.ActiveManagementCoordinator#attemptManageC3P0Registry : A C3P0Registry mbean is already registered. This probably means that an application using c3p0 was undeployed, but not all PooledDataSources were closed prior to undeployment. This may lead to resource leaks over time. Please take care to close all PooledDataSources. (2593 ms) [main] DEBUG: org.apache.struts2.config.PropertiesSettings#debug : struts.properties missing (2598 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for class com.opensymphony.xwork2.ObjectFactory (2598 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for class com.opensymphony.xwork2.conversion.impl.XWorkConverter (2598 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.TextProvider (2599 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.ActionProxyFactory (2599 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.conversion.ObjectTypeDeterminer (2599 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface org.apache.struts2.dispatcher.mapper.ActionMapper (2600 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (jakarta) for interface org.apache.struts2.dispatcher.multipart.MultiPartRequest (2600 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for class org.apache.struts2.views.freemarker.FreemarkerManager (2617 ms) [main] DEBUG: org.apache.struts2.config.BeanSelectionProvider#debug : Choosing bean (struts) for class org.apache.struts2.views.velocity.VelocityManager to be loaded from the ObjectFactory (2618 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface org.apache.struts2.components.UrlRenderer (2618 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.validator.ActionValidatorManager (2618 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.util.ValueStackFactory (2619 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionProvider (2619 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.util.reflection.ReflectionContextFactory (2619 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.util.PatternMatcher (2620 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface org.apache.struts2.dispatcher.StaticContentLoader (2620 ms) [main] INFO : org.apache.struts2.config.BeanSelectionProvider#info : Choosing bean (struts) for interface com.opensymphony.xwork2.UnknownHandlerManager (3794 ms) [main] DEBUG: org.apache.struts2.convention.PackageBasedActionConfigBuilder#debug : Processing class [com.auto.number.actions.PhoneNumAction] in package [com.auto.number.actions] (3817 ms) [main] DEBUG: org.apache.struts2.convention.PackageBasedActionConfigBuilder#debug : Processing class [com.auto.number.actions.UploadExcelDateAction] in package [com.auto.number.actions] 2015-12-14 10:38:59 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2015-12-14 10:38:59 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2015-12-14 10:38:59 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/42 config=null 2015-12-14 10:38:59 org.apache.catalina.startup.Catalina start 信息: Server startup in 145762 ms ```
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为什么会出现找到不模板的问题
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
JDK12 Collectors.teeing 你真的需要了解一下
前言 在 Java 12 里面有个非常好用但在官方 JEP 没有公布的功能,因为它只是 Collector 中的一个小改动,它的作用是 merge 两个 collector 的结果,这句话显得很抽象,老规矩,我们先来看个图(这真是一个不和谐的图????): 管道改造经常会用这个小东西,通常我们叫它「三通」,它的主要作用就是将 downstream1 和 downstre...
为啥国人偏爱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...
【图解经典算法题】如何用一行代码解决约瑟夫环问题
约瑟夫环问题算是很经典的题了,估计大家都听说过,然后我就在一次笔试中遇到了,下面我就用 3 种方法来详细讲解一下这道题,最后一种方法学了之后保证让你可以让你装逼。 问题描述:编号为 1-N 的 N 个士兵围坐在一起形成一个圆圈,从编号为 1 的士兵开始依次报数(1,2,3…这样依次报),数到 m 的 士兵会被杀死出列,之后的士兵再从 1 开始报数。直到最后剩下一士兵,求这个士兵的编号。 1、方...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
GitHub标星近1万:只需5秒音源,这个网络就能实时“克隆”你的声音
作者 | Google团队 译者 | 凯隐 编辑 | Jane 出品 | AI科技大本营(ID:rgznai100) 本文中,Google 团队提出了一种文本语音合成(text to speech)神经系统,能通过少量样本学习到多个不同说话者(speaker)的语音特征,并合成他们的讲话音频。此外,对于训练时网络没有接触过的说话者,也能在不重新训练的情况下,仅通过未知...
《程序人生》系列-这个程序员只用了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...
【技巧总结】位运算装逼指南
位算法的效率有多快我就不说,不信你可以去用 10 亿个数据模拟一下,今天给大家讲一讲位运算的一些经典例子。不过,最重要的不是看懂了这些例子就好,而是要在以后多去运用位运算这些技巧,当然,采用位运算,也是可以装逼的,不信,你往下看。我会从最简单的讲起,一道比一道难度递增,不过居然是讲技巧,那么也不会太难,相信你分分钟看懂。 判断奇偶数 判断一个数是基于还是偶数,相信很多人都做过,一般的做法的代码如下...
【管理系统课程设计】美少女手把手教你后台管理
【文章后台管理系统】URL设计与建模分析+项目源码+运行界面 栏目管理、文章列表、用户管理、角色管理、权限管理模块(文章最后附有源码) 1. 这是一个什么系统? 1.1 学习后台管理系统的原因 随着时代的变迁,现如今各大云服务平台横空出世,市面上有许多如学生信息系统、图书阅读系统、停车场管理系统等的管理系统,而本人家里就有人在用烟草销售系统,直接在网上完成挑选、购买与提交收货点,方便又快捷。 试想,若没有烟草销售系统,本人家人想要购买烟草,还要独自前往药...
4G EPS 第四代移动通信系统
目录 文章目录目录4G 与 LTE/EPCLTE/EPC 的架构E-UTRANE-UTRAN 协议栈eNodeBEPCMMES-GWP-GWHSSLTE/EPC 协议栈概览 4G 与 LTE/EPC 4G,即第四代移动通信系统,提供了 3G 不能满足的无线网络宽带化,主要提供数据(上网)业务。而 LTE(Long Term Evolution,长期演进技术)是电信领域用于手机及数据终端的高速无线通...
相关热词 c# 二进制截断字符串 c#实现窗体设计器 c#检测是否为微信 c# plc s1200 c#里氏转换原则 c# 主界面 c# do loop c#存为组套 模板 c# 停掉协程 c# rgb 读取图片
立即提问