Code: Select all
Nome
Salario
Requisitos
Carga Mínima
Desconto Impostos
Code: Select all
@Model
public class CargoCadastroModel {
@NotEmpty(message = "Informe o nome!") @Pattern(regexp = "^\\p{L}+(?: \\p{L}+)*$", message = "Nome inválido")
private String nome;
@NotEmpty(message = "Informe o salário!") @Pattern(regexp = "[0-9]d+,d{0,2}$", message = "Valor inválido")
private String salario;
@NotEmpty(message = "Informe os Requisitos!")
private String requisitos;
@NotEmpty(message = "Informe a carga mínima!") @Pattern(regexp = "[0-9]+$", message = "Valor inválido, somente números")
private String cargamin;
@NotEmpty(message = "Informe o imposto!") @Pattern(regexp = "[0-9]d+,d{0,2}$", message = "Valor inválido somente números")
private String descImpostos;
public CargoCadastroModel() {
}
Code: Select all
$(document).on('click', '#cadCargo', function (e) {
e.preventDefault(); // prevent standard form submission
var fdata = new FormData($('#formCargo')[0]);
debugger;
$.ajax({
type: 'post',
url: '/Rhindo/Gerente/AddCargo',
data: fdata,
async: false,
cache: false,
processData: false,
dataType: "html",
contentType: 'application/json',
success: function (content) {
debugger;
$("#cadModal").html(content);
},
});
return false;
});
Code: Select all
@RequestMapping(value = "/Gerente/AddCargo", method = RequestMethod.POST)
public String getFormCargo(@RequestBody @ModelAttribute("formCargo") @Valid CargoCadastroModel cargoModel, BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors()) {
model.addAttribute(cargoModel);
return "/gerente/cadastroCargo";
}
else{
}
return "/gerente/cadastroCargo";
}
Ich habe es gerade mit JSON.strignfy und Serialisierung versucht, aber nichts hat funktioniert
Bitte helfen Sie
Mobile version