Date: 2017.07.24 00:15 Categories:

  • Technology Blog Tags:
  • Framework using
  • SpringMVC

In the spirit of not reinventing the wheel, I won’t expand these two annotation uses in SpringMVC and will directly link to the blog that runs together: the difference between @pathVariable and @RequestParam.

On the one hand, he wrote this blog is complete, including the common parameter binding annotations (including my own common @modelattribute) together with a brief introduction. On the other hand, the structure is relatively clear, including usage, demo, explanation, so it is suitable for programmers who need reference.

Now that we have the usage and the simple understanding, let me talk a little bit.

SpringHome source, subjectively speaking, but also an objective fact: it is indeed clear, highly readable, although I have only seen part, but every time will let me have a kind of smooth reading feeling.

There are many reasons. From the perspective of framework design concept, there must be excellent genes, such as classic AOP, IOC, Spring’s reputation on this point is well known. Secondly, from the writing of code, this perspective is also where most junior and intermediate programmers can actually learn, that is, the specification problem. This is also the programmer engineering ability of the first pass.

Ali in a few months ago released ali Java coding specification downloadable e-book: “Alibaba Java Development Manual”, through this material, I think at least for Java programmers is to lower the threshold to improve their own, very practical, after all, Ali is a Large Java.

So much not to talk about, are in the PDF materials, as long as in accordance with such a style specification to develop their own coding habits, at least the quality of the code has the basic guarantee.

One of the most obvious aspects of Spring’s specification charm, I think, is naming. From classes to methods to variables, there is no nonsense. Here are some of the comments in this article:

  • @PathVariableThe logical processing of the variables takes place from the URL or URI of the request with dynamic parameters to the target method of the request
  • @RequestParam, translated as request parameters, can be understood as parameters carried in the REQ object, and is often used in cases with fewer parameters (without object encapsulation)
  • @ModelAttribute, translated as attributes in model, andSpringThe Model in is simply a bean used by the framework, and is often used when the name of the model and the front-end object are not identical in Java

Thus, the beauty of the specification is that, based on the basic usage of the framework, its annotation usage can be looked up in the API by name.

summary

  • Code doesn’t have to be elegant, but it’s best to be formal
  • Using a framework is about using it first and digging into the details later