1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package com.lavasoft.demo.web.controller.lsh.ch5; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; /** *
Created by Administrator on 14-4-9. * *
@author leizhimin 14-4-9 上午10:55 */ @Controller @RequestMapping( "/demo/lsh/ch5" ) @Scope( "prototype" ) public class MultViewController
{ private static int st
= 0 ; //靜態的 private int index
= 0 ; //非靜態 @RequestMapping( "/show" ) public String toShow(ModelMap
model) { User
user = new User(); user.setUserName( "testuname" ); user.setAge( "23" ); model.put( "user" ,
user); return "/lsh/ch5/show" ; } @RequestMapping( "/test" ) public String test()
{ System.out.println(st++
+ "
| " +
index++); return "/lsh/ch5/test" ; } } |
SpringMVC的controller默認是單例的!跟Struts2的action不一樣
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.