In Spring, @ RequestParam is used to accept url parameters of the Date type, @ requestparamdate
First introduce the joda-time package. Maven dependency:
<dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> <version>2.4</version> </dependency>
In the Controller code:
public String testMethod(@RequestParam @DateTimeFormat(pattern="yyyy-MM-dd") Date testdate){ System.out.println(testDate);}
Use pattern to specify the date format.
Test url:
? Testdate = 2014-09-04
Spring @ RequestParam
Use the following method:
@ RequestMapping ("/addHouse. do ")
Public String addHouse (
@ RequestParam (value = "companyId", required = true) int companyId,
@ RequestParam (value = "pics", required = false) CommonsMultipartFile pics,
HttpServletRequest request, HttpServletResponse response, ModelMap model ){
...
...
Model. addAttribute ("pics", pics );
Return "redirect:/addHousePic. do ";
Sample: addHousePic. do: pics null companyId can be successfully transferred.
What's going on?
Kltbsrexgt reference ·····
What problems have you encountered during spring's opening?
• @ Controller
• @ Service
• @ Autowired
• @ RequestMapping
• @ RequestParam
• @ ModelAttribute
• @ Cacheable
• @ CacheFlush
• @ Resource
• @ PostConstruct
• @ PreDestroy
• @ Repository
• @ Component (not recommended)
• @ Scope
• @ SessionAttributes
• @ InitBinder
• @ Required
• @ Qualifier
@ Controller
• Example
@ Controller
Public class SoftCreateController extends SimpleBaseController {}
• Or
@ Controller ("softCreateController ")
• Description
@ Controller registers a bean to the spring context. bean IDs start with the class name and start with lowercase letters by default.
@ Service
• Example
@ Service
Public class SoftCreateServiceImpl implements ISoftCreateService {}
• Or
@ Service ("softCreateServiceImpl ")
• Description
@ Service registers a bean to the spring context. bean IDs start with the class name and start with lowercase letters by default.
@ Autowired
• Example
@ Autowired
Private ISoftPMService softPMService;
• Or
@ Autowired (required = false)
Private ISoftPMService softPMService = new SoftPMServiceImpl ();
... The remaining full text>