Tomcat integrates development issues and solutions in Eclipse

xiaoxiao2021-03-06  66

Version: JDK 1.4.2 C: /JDK1.4ECLIPSE 2.1 C: / Eclipsetomcat 4.1.24 C: /tomcat4.1tomcat plugins: com.sysdeo.eclipse.tomcat_2.1.0 Tomcat Patch: JasperDebugpatchv4.1.24.zip Exes:

Servlet call problem JSP real-time compilation problem garbled problem JSP compilation debug problem

How to solve: 1.Servlet calling problem For many programmers developed servlets, such as inheriting the HTTPServlet program, want to call directly through the URL call, but found through: http: // localhost: 8080 / myWebapp / servlet / COM. AAA.BBB.MYSERVLETTEST will have an error, and the Tomcat prompts to find the corresponding resources, that is because Tomcat's default configuration is forbidden to call the servlet through the all-class name, how to open this option, look at Tomcat_Home / Conf / Web. xml

Code:

Invoker

Org.apache.catalina.servlets.invokerseervlet

debug

0

2

Code:

Invoker

/ servlet / *

For the second paragraph configuration is the key, it is to tell Tomcat All / servlet / **** requests all the send invoker's servlet, Tomcat default is comment, open it, all of WebApp can pass all The path is called servlet. What is INVOKER in the end, see the first configuration code, so when you are unsatisfactory to Tomcat's Invoker, you can replace the corresponding category of Invoker in the first segment configuration code. Note: For Examples in Tomcat, you can call servlet through the full path because Filter continues in the Web.xml of Examples, intercepting the default action of Tomcat, which is equivalent to overwriting Tomcat global settings. For the behavior of the Web Container, see the Sun specification.

Code:

servlet mapped filter

Invoker

path mapped filter

/ servlet / *

2. Many of the real-time compilation problems will find in Tomcat. For JSP just changed in IE, Tomcat does not compile the JSP file in real time, how to modify it? Similarly, see Tomcat_Home / Conf / Web.xml, find the JSP compiler for configuring, add the init-param parameter segment, tell Tomcat to perform Reloading every time, the date comparison, appropriate time to compile. For other parameters, you can see the parameters explained in web.xml, very specific.

Code:

JSP

org.apache.jasper.servlet.jspservlet

logverbositylevel

Warning

reloading

True

javaEncoding

GBK

3

Note: Org.apache.jasper.servlet.jspservlet, is why JSP can automatically convert into servlet, the question of JSP compile, can find the answer from it. Note that the JSP this servlet is mapping to * .jsp, so all JSP requests will be executed after being compiled into servlet, very similar to the AddType function in Apache.

Code:

JSP

*. jsp

3. Cottage problem garbled problem is more complicated, but as long as it finds why the problem is very simple. A.jsp page compiles to Chinese to become garbled B. The page output has garbled C. Transfer URL parameters or Chinese form field value, interprets to garbled for A sub-problems, because Tomcat's JASPER does not correctly identify JSP files Coding is caused, so you need to tell Jasper local JSP file encoding. Open tomcat_home / conf / web.xml, find the following configuration segment, give jsp plus parameter javaEncoding = GBK, where GBK is replaced with GB2312, everyone can ponder. Ha ha

Code:

jsp org.apache.jasper.servlet.jspservlet

logverbositylevel

Warning

reloading

True

javaEncoding

GBK

3

For the B sub-problem, it is very simple, plus the head of all JSP files: <% @ Page ContentType = "Text / HTML; Charset = GB2312"%> For C sub-problems, it is very simple, that is because Tomcat is The explanation of HTTP is transmitted in the ISO-8859-1, transmits the contents of the GB2312 of the front desk to the background, so it needs to be transcoded. For JSP files, add: Request.SetCharacterencoding ("GB2312") in all JSP files: Request.SetCharacterencoding; for servlet class: doget (...) {Request.setChacTerencoding ("GB2312"); ...) It can be done. 4.Jsp Compilation Debug Issue for the development of Eclipse using Tomcat Plugins, is very hoped to be able to be able to debug a JSP compiled servlet, but appear, after Tomcat's Jasper compile, Tomcat Plugins imported to Eclipse Workspace After the path is a problem that the path is not mismatched, this Tomcat Plugins provides patches that make Tomcat and Eclipse better coordination. Method: Different jasperdebugpatchv4.1.24.zip to tomcat_home / common / classes / under, OK! Can debug compilation in Eclipse, write so much first, throwing bricks! Attachment is JasperDebugPatchv4.1.24.zip, mainly to prevent everyone from being hard to find. There is also the version must pay attention to it, otherwise you will not work.

转载请注明原文地址:https://www.9cbs.com/read-121463.html

New Post(0)