一、中文字符乱码
1、修改webdefault.xml文件zh编码为utf-8
zh
UTF-8
2、在application.properties文件增加http编码配置
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
二、启动错误java.lang.RuntimeException: Error scanning entry module-info.class from jar ...
详细错误:
2018-07-17 08:08:15.981:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@34b7bfc0{/mp_store,file:/usr/local/jetty-9.2.25/webapps/mp_store/,STARTING}{/mp_store}
java.lang.RuntimeException: Error scanning entry module-info.class from jar file:/usr/local/jetty-9.2.25/webapps/mp_store/WEB-INF/lib/asm-all-repackaged-2.5.0-b32.jar
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:913)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:831)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:164)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:549)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)
Caused by:
java.lang.IllegalArgumentException
at org.objectweb.asm.ClassReader.(Unknown Source)
at org.objectweb.asm.ClassReader.(Unknown Source)
at org.objectweb.asm.ClassReader.(Unknown Source)
at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:973)
at org.eclipse.jetty.annotations.AnnotationParser.parseJarEntry(AnnotationParser.java:956)
at org.eclipse.jetty.annotations.AnnotationParser.parseJar(AnnotationParser.java:909)
at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:831)
at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:164)
at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:549)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)
原因是asm-all-repackaged-2.5.0-b32.jar编译的jdk9,而服务器我配置的是jdk8,因此降低asm-all-repackaged版本,
org.glassfish.hk2.externalasm-all-repackaged2.4.0
三、配置contextPath
在webapps目录,默认以war包的名字作为contextPath。比如war包名为test.war,那么contextPath就为test。当然如果war包是root.war,那么contextPath为“/”。
另外可以在webapps目录增加war包名对应的xml文件实现配置与war包名不同的contextPath。如war包为test.war,则对应增加test.xml文件,内容如下:
/test1
/webapps/test.war
这样就设置contextPath为test1了。对应的url就为http://localhost:8080/test1
四、修改jetty端口
jetty9修改端口方法:
修改start.ini文件的jetty.port的值即可