Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bdeb73b

Browse files
Aula 07 - Arquivos Finais
1 parent b96cbee commit bdeb73b

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
eclipse.preferences.version=1
22
encoding//src/main/java=UTF-8
33
encoding//src/main/resources=UTF-8
4+
encoding//src/main/webapp/WEB-INF/message.properties=UTF-8
45
encoding//src/test/java=UTF-8
56
encoding//src/test/resources=UTF-8
67
encoding/<project>=UTF-8

‎casadocodigo/src/main/java/br/com/casadocodigo/loja/conf/AppWebConfiguration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package br.com.casadocodigo.loja.conf;
22

3+
import org.springframework.context.MessageSource;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.ComponentScan;
6+
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
57
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
68
import org.springframework.web.servlet.view.InternalResourceViewResolver;
79

@@ -20,4 +22,14 @@ public InternalResourceViewResolver internalResourceViewResolver() {
2022

2123
return resolver;
2224
}
25+
26+
@Bean
27+
public MessageSource messageSource() {
28+
ReloadableResourceBundleMessageSource messageSource =
29+
new ReloadableResourceBundleMessageSource();
30+
messageSource.setBasename("/WEB-INF/messages");
31+
messageSource.setDefaultEncoding("UTF-8");
32+
messageSource.setCacheSeconds(1);
33+
return messageSource();
34+
}
2335
}

‎casadocodigo/src/main/java/br/com/casadocodigo/loja/controllers/ProdutosController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import br.com.casadocodigo.loja.validation.ProdutoValidation;
2121

2222
@Controller
23-
@RequestMapping("produtos")
23+
@RequestMapping("/produtos")
2424
public class ProdutosController {
2525

2626
@Autowired
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
field.required = Campo obrigatrio.
2+
field.required.produto.titulo = O Campo título é obrigatório.
3+
field.required.produto.numeros = Informe o número de páginas.
4+
field.required.produto.descricao = O campo descrição é obrigatório.
5+
typeMismatch = O tipo de dado foi inválido
6+
typeMismatch.produto.numeros = DIgite um valor válido. Exemplo: "100"
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<%@ page language="java" contentType="text/html; charset=UTF-8"
22
pageEncoding="UTF-8"%>
33
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4+
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
5+
<%@ taglib uri="http://www.springframework.org/tags" prefix="s"%>
46
<!DOCTYPE html>
57
<html>
68
<head>
@@ -9,16 +11,21 @@
911
Casa do Código</title>
1012
</head>
1113
<body>
12-
<form action="/casadocodigo/produtos" method="post">
14+
<form:form action="${s:mvcUrl('PC#gravar').build()}" method="post"commandName="produto">
1315
<div>
14-
<label>Titulo</label> <input type="text" name="titulo">
16+
<label>Titulo</label>
17+
<input type="text" name="titulo">
18+
<form:errors path="titulo"/>
1519
</div>
1620
<div>
1721
<label>Descrição</label>
1822
<textarea rows="10" cols="20" name="descricao"></textarea>
23+
<form:errors path="descricao"/>
1924
</div>
2025
<div>
21-
<label>Páginas</label> <input type="text" name="paginas">
26+
<label>Páginas</label>
27+
<input type="text" name="paginas">
28+
<form:errors path="paginas"/>
2229
</div>
2330
<c:forEach items="${tipos}" var="tipoPreco" varStatus="status">
2431
<div>
@@ -28,6 +35,6 @@
2835
</div>
2936
</c:forEach>
3037
<button type="submit">Cadastrar</button>
31-
</form>
38+
</form:form>
3239
</body>
3340
</html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /