背景交代:
上一篇博客写的是用jetty和Maven做开发、測试。在使用的过程中遇到一个小问题。就是在jetty启动以后,改动了jsp、xml等文件无法保存。
错误信息:
解决方式:
到Maven库(即repository)中搜索jetty-webapp,例如以下图:
将jetty-webapp*.jar文件拷贝到桌面,用压缩软件打开,到"\org\eclipse\jetty\webapp"文件夹下,或者直接在压缩软件中搜索"webdefault.xml",如图:
找到"webdefault.xml"文件,用压缩软件自带的查看器或者记事本之类的软件打开,然后搜索"useFileMappedBuffer"
<init-param>
<param-name>useFileMappedBuffer</param-name>
<param-value>false</param-value>
</init-param>
将"true"改为false,然后保存,将改动后的jar包拷贝到原来的位置替换掉之前的jar包。
或者将webdefault.xml文件放到项目中(如放到"src/main/resources"文件夹下),在pom.xml文件的<webAppConfig>标签中增加下面代码:
<webAppConfig>
<contextPath>/${project.artifactId}</contextPath>
<defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor>
</webAppConfig>
PS:假设经过上述步骤还是不能解决。重新启动jetty或者Eclipse就可以。