File tree Expand file tree Collapse file tree 8 files changed +60
-25
lines changed
java/com/itacademy/CrudEmpleats/controller Expand file tree Collapse file tree 8 files changed +60
-25
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,9 @@ void start(HttpServletResponse reponse) throws IOException {
31
31
// Crear nou empleat
32
32
@ PostMapping ( "/EmpleatList" )
33
33
@ ResponseStatus (HttpStatus .CREATED ) // 201
34
- public Employee addEmployee (@ RequestBody Employee employee ) {
34
+ public void addEmployee (@ RequestBody Employee employee ) {
35
35
repositori .addEmployee (employee );
36
- return employee ;
36
+
37
37
}
38
38
39
39
// Retorna una llista JSon d'empleats
Original file line number Diff line number Diff line change @@ -9,14 +9,15 @@ public class ControllerWeb {
9
9
* Controlador d'accés html
10
10
*/
11
11
12
+
12
13
@ GetMapping ("/index" )
13
14
public String goIndex () {
14
15
return "index" ;
15
16
}
16
-
17
- @ GetMapping ("/BodyHeader " )
17
+
18
+ @ GetMapping ("/ModificarEmpleat " )
18
19
public String bodyHeader () {
19
- return "BodyHeader " ;
20
+ return "ModificarEmpleat " ;
20
21
}
21
22
22
23
}
Original file line number Diff line number Diff line change 1
-
2
- spring.mvc.static-path-pattern =/content/**
Original file line number Diff line number Diff line change
1
+
2
+ $ ( document ) . ready ( function ( ) {
3
+ $ ( '#newEmployee' ) . submit ( function ( evento ) {
4
+ $ . ajax ( {
5
+ url : '/EmpleatList' ,
6
+ type : 'POST' ,
7
+ data : JSON . stringify ( {
8
+ "name" : $ ( '#name' ) . val ( ) ,
9
+ "job" : $ ( '#job' ) . val ( )
10
+ } ) ,
11
+ processData : false ,
12
+ contentType : "application/json"
13
+ } )
14
+ evento . preventDefault ( ) ;
15
+ } ) ;
16
+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 9
9
< div >
10
10
< H4 > Modificar empleat</ H4 >
11
11
</ div >
12
- < div >
13
12
< div class ="container ">
14
- < div th:insert ="Fragments/BodyHeader :: div "> </ div >
15
13
< form action ="/ " method ="post ">
16
14
#: < input type ="text " name =id >
17
15
Nom: < input type =text name =name >
Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
2
< html >
3
+
3
4
< head >
4
5
< meta charset ="UTF-8 ">
5
6
< title > Spring - Crud Empleats</ title >
7
+
8
+ <!--Libreria Jquery carcada des de CDN-->
9
+ < script src ="https://code.jquery.com/jquery-3.6.0.min.js "> </ script >
10
+
6
11
</ head >
12
+
7
13
< body >
8
14
< div class ="container "> </ div >
9
15
< div >
@@ -34,5 +40,37 @@ <H4>Empleats</H4><button type="submit">Nou Empleat</button>
34
40
</ table >
35
41
</ div >
36
42
</ div >
43
+ < div class ="container "> </ div >
44
+ < div >
45
+ < H4 > Crear Empleat</ H4 >
46
+ </ div >
47
+ < div >
48
+ < div class ="container ">
49
+ < div > </ div >
50
+ < form id ="newEmployee " action ="# " method ="post ">
51
+ < div >
52
+ Nom: < input type =text name =name id ="name ">
53
+ </ div >
54
+ < div >
55
+ Càrreg:
56
+ < select name ="job " id ="job ">
57
+ < option value ="Default "> Escull un càrreg</ option >
58
+ < option value ="Director_Projectes "> Director de projectes</ option >
59
+ < option value ="Programador_Senior "> Programador Senior</ option >
60
+ < option value ="Programador_Mid "> Programador Mid-Level</ option >
61
+ < option value ="Programador_Junior "> Programador Junior</ option >
62
+ < option value ="Administrativa "> Administrativa</ option >
63
+ </ select >
64
+ </ div >
65
+ < div >
66
+ < br > < br >
67
+ < input type =submit name ="submit " value ="Afegir ">
68
+ < input type =reset value ="Cancellar ">
69
+ </ div >
70
+ </ form >
71
+ </ div >
72
+ </ div >
73
+ < script type ="text/javascript " src ="index.js "> </ script >
37
74
</ body >
75
+
38
76
</ html >
You can’t perform that action at this time.
0 commit comments