Retinal layer thickness is one of the important indicators for diagnosing ophthalmic diseases, therefore, automatic segmentation and quantitative calculation of the retinal layer are of great significance. However, currently in retinal optical coherence tomography images, there are many problems with retinal stratification, such as the lack of contextual semantic information due to blurred boundaries of each layer of the retina, and the discontinuity in the pathological change region. In this paper, a novel dense encoder and position attention method which is introduced into the encoding and decoding architecture is proposed to improve the precision of retinal layer segmentation and measurement. The dense encoder block can learn and extract more diverse the global context, and the position attention is to ensure the spatial consistency of retinal targets boundaries and regions, to improve the imbalance between retinal layer boundaries and obtain more continuous prediction classes for the same retinal layer structure. The validation results demonstrate that our proposed method achieved an average dice of 87.35%, and the average thickness error of the retinal layers was reduced to 1.74 pixels. In particular, it provides an effective strategy to improve the boundaries of segmentation and accurately segment and measure the retinal layers.