Java Little Brother 9:39:24
Did you see me call?
The melody of the Wind 9:39:28
Brother's meeting.
The melody of the Wind 9:39:30
Nonsense
The melody of the Wind 9:39:34
You hit it, everybody saw it.
Java Little Brother 9:39:38
I didn't show it.
Java Little Brother 9:39:47
I thought I didn't send it.
Java Little Brother 9:40:08
The problem that bothered me for 3 days has finally been solved under my brilliant mind.
Java Little Brother 9:40:15
wow haha
The melody of the Wind 9:40:33
You're going to have to give it back to the cows. This group is not going to get you so many times.
Java Little Brother 9:40:34
But I'm not quite familiar with the spring MVC pattern.
Dbac 9:41:00
。。。。
Dbac 9:41:15
Brother, what's your problem?
The melody of the Wind 9:41:22
Brother went to the lecture.
Java Little Brother 9:41:40
Is that spring's interceptors are ineffective.
Dbac 9:41:46
Why not?
Java Little Brother 9:41:54
I'm using a spring3.1.
Java Little Brother 9:42:04
I don't know, it's been bothering me.
Java Little Brother 9:42:31
I write a demo on my own, set <mvc:intercetors> no problem
Dbac 9:42:56
You don't know how to solve a p.
Java Little Brother 9:43:05
And then it was settled.
Java Little Brother 9:43:09
Ha ha
Java Little Brother 9:43:24
New projects are written using annotations.
Java Little Brother 9:43:49
3.1 Chinese things are very few
Dbac 9:43:55
You solve a p, you don't know the problem.
Java Little Brother 9:45:04
I search English in a single meal
Java Little Brother 9:45:19
No work, avaliable
Java Little Brother 9:45:26
I'm so talented.
Java Little Brother 9:47:16
It was later found that using annotations <annotation-driven/>, the defaultannotationhandlermapping and simplehandlermapping are loaded automatically. After the bean definition for defaultannotationhandlermapping, it is invalid
Java Little Brother 9:47:28
Pre-loading
Java Little Brother 9:48:08
<mvc:intercetors> works because he handlermapping all the interceptors settings.
Java Little Brother 9:49:02
Can not find reliable information on the internet, I looked at the API, the official sample is also a custom bean with XML
Java Little Brother 9:49:40
Later, I looked up the API and added a sentence setorder (0) to define the annotation way, so that he first defined defaultannotationhandlermapping,
Java Little Brother 9:49:46
The problem is solved.
Java Little Brother 9:49:48
Ha ha
Java Little Brother 9:51:04
Priority written in the first, so <annotation-driven/>, he found that the order is 0 will cover the original defaultannotationhandlermapping.
Java Little Brother 9:51:45
But now the problem is solved, I still do not know exactly order=0 the original walk is which mapping. Also need to study MVC to have a good look.
Java Little Brother 9:51:51
I'm going to mutter about it.
Java Little Brother 9:52:11
Although no one to ignore me, but I am happy to share their experience with you.
Dbac 9:52:14
Yes, thank you.
Dbac 9:52:18
have been looking at hehe
Java Little Brother 9:52:22
Acclamation
Dbac 9:52:33
Java Little Brother 9:54:13
Based on the annotation is a bit bad, that is, when the release, if it is XML customization, the release of the time to change the XML is OK. But the annotation way, although the code is simple, the XML looks not very fidgety, but once changes, needs each time changes the source code, again publishes. This one.... It may be necessary to write an automatic thing to publish, otherwise, it will be very fidgety. Hehe
Code fragment:
@Bean public
defaultannotationhandlermapping handlermapping () {
defaultannotationhandlermapping Handlermapping =new defaultannotationhandlermapping ();
Controllerinterceptor intercepter=new controllerinterceptor ();
Handlermapping.setinterceptors (New Object[]{intercepter});
Handlermapping.setorder (0);
return handlermapping;
}