编程知识 cdmana.com

Java common interview questions (you are only one step away from the offer)

1、 Talk a SpringMvc What is the core entry class of ,Struts1,Struts2 What are the differences between

SpringMvc Yes. DispatchServlet,Struts1 Yes. ActionServlet,Struts2 Yes. StrutsPrepareAndExecuteFilter

2、SpringMvc Is the controller in singleton mode , If it is , What's the problem? , How to solve

It's the singleton mode , So there are thread security issues when accessing multiple threads , Don't use sync , It will affect performance , The solution is that fields cannot be written in the controller

3、SpingMvc The controller annotation in is usually the , Is there any other annotation to replace

It's usually used @Conntroller annotation , It means the presentation layer , You can't substitute other notes for .

4、@RequestMapping What's the use of annotations on classes

For classes , This address is the parent path of all methods in the class that respond to requests .

5、 How to map a request to a specific method

Annotate the method directly @RequestMapping, And write the path to intercept in this annotation

6、 If in the intercept request , I want to intercept get Method of submission , How to configure

Can be in @RequestMapping Add... To the note method=RequestMethod.GET

7、 If in the intercept request , I want to block submission parameters that contain ”type=test” character string , How to configure

Can be in @RequestMapping Add... To the note params=”type=test”

8、 I want to get the parameters passed in from the front station in the interception method , How to get

You can declare this parameter directly in the parameter , But the name must be the same as the parameter passed

9、 If the foreground has many parameters passed in , And these parameters are all the parameters of an object , So how to get this object quickly

Declare the object directly in the method ,SpringMvc It will automatically assign properties to this object

10、 How to get... In the method Request, perhaps Session

Declare... Directly in the parameter of the method request,SpringMvc Just put request Object to

11、SpringMvc What is the return value of the function in .

There are many types of return values , Yes String, ModelAndView, When used in general String better

12、SpringMvc How to deal with the return value of

SpringMvc According to the configuration file InternalResourceViewResolver Prefixes and suffixes for , Use prefix + Return value + Suffixes make up the complete return value

13、SpringMVC How to set redirection and forwarding

Add... Before the return value ”forward:” You can forward the results , for example ”forward:user.do?name=method4” Add... Before the return value ”redirect:” You can redirect the return value , for example ”redirect: use Baidu Search , You will know

14、 SpringMvc What object is used to transfer data from the background to the front desk

adopt ModelMap object , It can be used in this object put Method , Add objects to it , You can go through the front desk el The expression gets

15、SpringMvc There's a class in that merges views and data , What is called?

It's called ModelAndView

16、 How to put ModelMap Put the data in Session Inside

You can add... To the class @SessionAttributes annotation , The string contained in it is to put session Inside key

17、SpringMvc How and AJAX Calling each other

adopt Jackson The frame can put Java The objects in it are directly transformed into Js Recognizable Json object

The specific steps are as follows

1. Join in Jackson.jar

2. Configure in profile json Mapping

3. In an interview with Ajax Method can directly return to Object,List etc. , But add... Before the method @ResponseBody annotation

18、 When a way to AJAX Return special object , for example Object,List etc. , What needs to be done

To add @ResponseBody annotation

19、SpringMvc How is the interceptor written inside

There are two ways of writing , One is to implement interfaces , The other is the inheritance adapter class , And then in SpringMvc The interceptor can be configured in the configuration file of :

<!-- Block only for partial requests -->

<mvc:interceptor>

<mvc:mapping path="/modelMap.do" />

<bean class="com.et.action.MyHandlerInterceptorAdapter" />

</mvc:interceptor>

20、 Talk a SpringMvc The implementation process of

When the system is started, it is created according to the configuration file spring The container of , The first is to send http Request to core controller disPatherServlet,spring The container uses the mapper to find the business controller ,

Use the adapter to find the corresponding business class , Data encapsulation when entering business class , Type conversion may be involved before encapsulation , Use... After executing the business class ModelAndView Forward the view , The data is in model in , use map Transfer data for page display .

21、Spring MVC An introduction to the :

1、 Can be inserted MVC framework . This architecture can be implemented through a : Built in spring web frame Two is :Struts Web frame To achieve .

2、spring.xml You can also use the policy interface to realize the framework height configuration , namely : Multiple view technologies can be configured , Such as :jsp velocity tiles iTest POI

3、Spring MVC Separate the controller 、 Model object 、 Roles of dispatchers and handler objects

22、Spring MVC The advantages of :

1、 Easy access view Seamless integration of framework , use IOC To facilitate the test

2、 Typically pure MVC The architecture ,Struts It's not entirely based on MVC Framework of the

3、 And tapestry It's pure Servlet System ,( This is also relative to Struts The advantages of )

 

Based on my many years of working experience and learning experience , Recorded a new set of Java Focus on video tutorials , If you are learning now Java, At the beginning of learning Java There is no systematic learning course in the process , You can add QQ Group 654631948 Collect the learning materials , Interview questions , Development tools, etc , There are senior people in the group java The teacher answers questions , Every day, there will also be live lectures on the basic part and architecture , You can also add my wechat renlliang2013 In depth communication , As long as I really want to learn Java People welcome .


java Basic course :https://ke.qq.com/course/149432?tuin=57912c43

Java Distributed Internet Architecture / Microservices / High performance /springboot/springcloud:

https://ke.qq.com/course/179440?tuin=57912c43

版权声明
本文为[renlianggee]所创,转载请带上原文链接,感谢

Scroll to Top