Gradle-simple test driver Web program

Source: Internet
Author: User

Gradle-simple test driver Web program

# Platform Ubuntu Linux
# Project name (top-level directory name) tdd
# The jar package used
Servlet-api.jar
Org. springframework. core-3.0.4.RELEASE.jar
Commons-logging-1.0.4.jar
Spring-mock.jar

1. Implement an example of Echo Request Parameters in plain text based on servlet.
1) Compile EchoServlet code
Because gradle needs to be used for automatic building, it follows the directory conventions of the java project in gradle.

> Mkdir-p src/main/java/com/thoughtworks/servlet
> Cd src/main/java/com/thoughtworks/servlet
> Touch EchoServlet. java

 

Package com. thoughtworks. servlet;

Import java. io. IOException;
Import java. io. PrintWriter;
Import java. util. Enumeration;

Import javax. servlet. ServletException;
Import javax. servlet. http. HttpServlet;
Import javax. servlet. http. HttpServletRequest;
Import javax. servlet. http. HttpServletResponse;

Public class EchoServlet extends HttpServlet {

@ Override
Public void doGet (HttpServletRequest request, HttpServletResponse response)
Throws ServletException, IOException {
Response. setHeader ("Content-Type", "text/plain"); // you can specify a plain text response header.
PrintWriter writer = response. getWriter ();
Enumeration e = request. getParameterNames (); // get the request parameter name
While (e. hasMoreElements ()){
String name = String. valueOf (e. nextElement ());
String [] values = request. getParameterValues (name );
For (String v: values ){
Writer. write (name + "=" + v );
Writer. write ("\ n ");
}
}
Writer. close ();
}
}

For more details, please continue to read the highlights on the next page:

Gradle details: click here
Gradle: click here

Gradle

Gradle packages Groovy scripts into jar and uploads them to maven repository

How to solve common problems of building Android applications using Gradle

  • 1
  • 2
  • 3
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.