Solve the problem that Jetty and HTML and Js code cannot be saved

Configure
<webAppConfig>
<contextPath>/</contextPath>
<defaultsDescriptor>src/main/resources/webdefault.xml</defaultsDescriptor>
</webAppConfig>












  Jetty is an open source servlet container for Java-based web content such as JSP And servlet provides the runtime environment. Jetty is written in the Java language, and its API is distributed as a set of JAR packages. Developers can instantiate the Jetty container as an object that can quickly provide network and web connectivity for some stand-alone Java applications.



The latest version of Jetty is now 7.0; Eclipse is fully supported. For more information, please check http://hi.baidu.com/dfdkfdeijf/blog/item/cb46ed1ded0c9f0f8618bfab.html;



    the project has just been managed by Maven, which is very different from the previous development and debugging environment. The most painful thing is to debug HTML and js code since it has to be repackaged and released. The final solution is to use Jetty.
Using Jetty under Maven is very simple. First, Jetty is referenced in Maven, and then the following configuration is required:





Click run, the system will run jetty and start the web project. No need to use tomcat anymore. Because both tomcat and Jetty can be used as servelt containers, jetty replaces tomcat here.



But then encountered a problem. In development, html and js code are often modified, and it is found that as long as the html or js accessed by the browser is locked, it cannot be saved after modification, whether it is saved in Eclipse or externally.



Later, I found the reason on the Internet: jetty caches static html, js and css, etc., which cannot be modified, but JSP files can be modified.



The solution is to modify useFileMappedBuffer in webdefault.xml in jetty jar to false

<init-param>
  <param-name>useFileMappedBuffer</param-name>
  <param-value>false</param-value> The default is true

</init -param>

Next is to find webdefault.xml:
in 6.0 and earlier versions, all jetty classes are in a jar.

In version 7.0, jetty has been split into many jar packages, and this xml file is located in jetty-webapp.jar.

Open the jar with rar tool and find webdefault.xml under org/eclipse/jetty/webapp.



On my computer: the jar package exists in the

C:/Documents and Settings/xxxx/.m2/repository/org/eclipse/jetty/jetty-webapp/7.1.4.v20100610 directory;

The specific name is jetty-webapp-7.1.4.v20100610.jar Modify the useFileMappedBuffer of webdefault.xml to false,

restart the web by jetty, it is successful, you can modify and save html and js normally

Sunny
MSN: [email protected]

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326985672&siteId=291194637