How to set each controller a default url or requestMapping in springMVC
up vote
1
down vote
favorite
For example:the class which is a controller has a requestMapping @RequestMapping("/company")
,and it has a method named "index".
In this case,how can i input a url like '/company' or '/company/' and enter the method named "index"?
java spring-mvc
New contributor
add a comment |
up vote
1
down vote
favorite
For example:the class which is a controller has a requestMapping @RequestMapping("/company")
,and it has a method named "index".
In this case,how can i input a url like '/company' or '/company/' and enter the method named "index"?
java spring-mvc
New contributor
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
For example:the class which is a controller has a requestMapping @RequestMapping("/company")
,and it has a method named "index".
In this case,how can i input a url like '/company' or '/company/' and enter the method named "index"?
java spring-mvc
New contributor
For example:the class which is a controller has a requestMapping @RequestMapping("/company")
,and it has a method named "index".
In this case,how can i input a url like '/company' or '/company/' and enter the method named "index"?
java spring-mvc
java spring-mvc
New contributor
New contributor
edited Nov 5 at 3:44
Gurwinder Singh
32k52448
32k52448
New contributor
asked Nov 5 at 3:33
wenyang.chou
61
61
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
There are several ways to do it. One of the example, to use @RequestMapping
on method and specify request type:
@RequestMapping(value = "/foos", method = RequestMethod.GET)
@ResponseBody
public String getFoos() {
return "Get some Foos";
}
@RequestMapping(value = "/foos", method = RequestMethod.POST)
@ResponseBody
public String postFoos() {
return "Post some Foos";
}
More details and examples.
I was a little wrong.thank you very much
– wenyang.chou
Nov 5 at 6:06
add a comment |
up vote
0
down vote
You could use @RequestMapping
with multiple paths like this,
@RequestMapping(value = {"/company", "/company/"}, method = RequestMethod.GET)
(It has String
as value
parameter)
this way is very well,thanks
– wenyang.chou
Nov 5 at 6:07
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
There are several ways to do it. One of the example, to use @RequestMapping
on method and specify request type:
@RequestMapping(value = "/foos", method = RequestMethod.GET)
@ResponseBody
public String getFoos() {
return "Get some Foos";
}
@RequestMapping(value = "/foos", method = RequestMethod.POST)
@ResponseBody
public String postFoos() {
return "Post some Foos";
}
More details and examples.
I was a little wrong.thank you very much
– wenyang.chou
Nov 5 at 6:06
add a comment |
up vote
0
down vote
There are several ways to do it. One of the example, to use @RequestMapping
on method and specify request type:
@RequestMapping(value = "/foos", method = RequestMethod.GET)
@ResponseBody
public String getFoos() {
return "Get some Foos";
}
@RequestMapping(value = "/foos", method = RequestMethod.POST)
@ResponseBody
public String postFoos() {
return "Post some Foos";
}
More details and examples.
I was a little wrong.thank you very much
– wenyang.chou
Nov 5 at 6:06
add a comment |
up vote
0
down vote
up vote
0
down vote
There are several ways to do it. One of the example, to use @RequestMapping
on method and specify request type:
@RequestMapping(value = "/foos", method = RequestMethod.GET)
@ResponseBody
public String getFoos() {
return "Get some Foos";
}
@RequestMapping(value = "/foos", method = RequestMethod.POST)
@ResponseBody
public String postFoos() {
return "Post some Foos";
}
More details and examples.
There are several ways to do it. One of the example, to use @RequestMapping
on method and specify request type:
@RequestMapping(value = "/foos", method = RequestMethod.GET)
@ResponseBody
public String getFoos() {
return "Get some Foos";
}
@RequestMapping(value = "/foos", method = RequestMethod.POST)
@ResponseBody
public String postFoos() {
return "Post some Foos";
}
More details and examples.
answered Nov 5 at 3:43
uli
367212
367212
I was a little wrong.thank you very much
– wenyang.chou
Nov 5 at 6:06
add a comment |
I was a little wrong.thank you very much
– wenyang.chou
Nov 5 at 6:06
I was a little wrong.thank you very much
– wenyang.chou
Nov 5 at 6:06
I was a little wrong.thank you very much
– wenyang.chou
Nov 5 at 6:06
add a comment |
up vote
0
down vote
You could use @RequestMapping
with multiple paths like this,
@RequestMapping(value = {"/company", "/company/"}, method = RequestMethod.GET)
(It has String
as value
parameter)
this way is very well,thanks
– wenyang.chou
Nov 5 at 6:07
add a comment |
up vote
0
down vote
You could use @RequestMapping
with multiple paths like this,
@RequestMapping(value = {"/company", "/company/"}, method = RequestMethod.GET)
(It has String
as value
parameter)
this way is very well,thanks
– wenyang.chou
Nov 5 at 6:07
add a comment |
up vote
0
down vote
up vote
0
down vote
You could use @RequestMapping
with multiple paths like this,
@RequestMapping(value = {"/company", "/company/"}, method = RequestMethod.GET)
(It has String
as value
parameter)
You could use @RequestMapping
with multiple paths like this,
@RequestMapping(value = {"/company", "/company/"}, method = RequestMethod.GET)
(It has String
as value
parameter)
answered Nov 5 at 4:17
benjamin c
1,225316
1,225316
this way is very well,thanks
– wenyang.chou
Nov 5 at 6:07
add a comment |
this way is very well,thanks
– wenyang.chou
Nov 5 at 6:07
this way is very well,thanks
– wenyang.chou
Nov 5 at 6:07
this way is very well,thanks
– wenyang.chou
Nov 5 at 6:07
add a comment |
wenyang.chou is a new contributor. Be nice, and check out our Code of Conduct.
wenyang.chou is a new contributor. Be nice, and check out our Code of Conduct.
wenyang.chou is a new contributor. Be nice, and check out our Code of Conduct.
wenyang.chou is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147969%2fhow-to-set-each-controller-a-default-url-or-requestmapping-in-springmvc%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password