changes for servlet
This commit is contained in:
parent
8123ba6442
commit
e375a00a09
|
@ -18,6 +18,11 @@
|
|||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>${javax.servlet.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
@ -30,11 +35,6 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
|
|
|
@ -25,9 +25,9 @@ public class EmployeeServlet extends HttpServlet {
|
|||
Double salary = Double.parseDouble(request.getParameter("salary"));
|
||||
|
||||
Employee employee = new Employee(id, name, department, salary);
|
||||
String employeeJsonString = new Gson().toJson(employee);
|
||||
|
||||
PrintWriter out = response.getWriter();
|
||||
String employeeJsonString = new Gson().toJson(employee);
|
||||
response.setContentType("application/json");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
out.print(employeeJsonString);
|
||||
|
|
Loading…
Reference in New Issue