cainawuha / Pro-Spring-5th-notes

0 stars 0 forks source link

web application #4

Open cainawuha opened 3 years ago

cainawuha commented 3 years ago

To create the table you won’t use this SQL script; instead, Hibernate will generate the SQL necessary to create the table based on the configuration of the Singer entity that is depicted by the following code snippet:

Implementing the DAO Layer :we will use Spring Data JPA’s repository support, we will implement the SingerRepository interface, public interface SingerRepository extends PagingAndSortingRepository<Singer, Long> { }

Implementing the Service Layer: public interface SingerService { List findAll(); Singer findById(Long id);}

public class SingerServiceImpl implements SingerService {call to the repository methods}

  1. Request: A request is submitted to the server. On the server side, most frameworks (for example, Spring MVC or Struts) have a dispatcher (in the form of a servlet) to handle the request.
  2. Invokes: The dispatcher dispatches the request to the appropriate controller based on the HTTP request information and the web application configuration.
  3. Service call: The controller interacts with the service layer.
  4. Model is populated: The information obtained from the service layer is used by the controller to populate a model.
cainawuha commented 3 years ago

springSecurityFilterChain, and it was applied to any requests, except the one for static components.springSecurityFilterChain, and it was applied to any requests, except the one for static components.

we cover how to create a full-blown web application with security and web pages created using Thymeleaf. Thymeleaf is an XML/XHTML/HTML5 template engine that can work both in web and nonweb environments.

if spring-boot-starter-security is in the classpath, Spring Boot automatically secures all HTTP endpoints with basic authentication. But the default security settings can be further customized

By default Spring Boot configures the Thymeleaf engine to read template files from the templates directory. If Spring MVC is being used alone, without Spring Boot, the Thymeleaf engine needs to be explicitly configured by defining three beans: a bean of type SpringResourceTemplateResolver, a bean of type SpringTemplateEngine, and a ThymeleafViewResolver bean.9 Thus, with Spring Boot, all the developer has to do is start creating templates and drop them into the /resources/templates directory.

<input type="text" name="singerName" value="John Mayer" th:value="${singer.name}" /> With the previous declaration, the browser is able to display the element, and you can actually set a value for the element so we can see how components come together in the page. This value will be replaced by the result of the evaluation of ${singer.name} during processing of the template.