My Java MVC

Source: Internet
Author: User
Tags button type

Mint MVC was not my original. She is based on Webwind MVC, the teacher of Liu Xuefeng. Webwind is a rest-style MVC framework, which is simple, but the core function of MVC is basic, I think it is very good design idea, it is suitable for the learners who want to understand MVC. I made the following modifications on his basis:
1, improved the URL parameter matching method, originally supported 9 URL parameters (1-9), now support is a URL parameter (0-9). There are two main benefits after the change. First: Support the number of URL parameters to increase one; second: the computer count method, many arrays in the code do not have to do special processing, simplifying the code.
2, some logic more complex classes were split.
3, support the automatic acquisition of request parameters and encapsulated in the bean, for the action method to use. Currently supported types include: array type, wrapper class of the underlying type, generic model class (contains attributes that temporarily support only the underlying type and its wrapper class, and must have a corresponding setter method). If an action method contains the underlying type (non-wrapper class), the method is not a valid action method, which is to avoid the need for expediency when the underlying type argument cannot be given null when the action method is called by reflection.
4. You can declare that an action method can only handle requests for a particular method, and currently only supports the Get and post methods.
? 1. [Code] A typical action class is as follows

Package demo;
import annotation. Get;
import annotation. Mapping;
import annotation. Param;
import annotation. Post;

@Mapping ("/user")
public class Useraction {
@Mapping ("/login")
public string Hello (@Param ("phone") string phone, @Param ("user") user user) {
Return "}

@Get
@Mapping ("/register")
Public String Register (Integer a) {
return "}

@Post
@Mapping ("/confirm/$0")/*$+paramindex*/
public void confirm (String name, @Param ("hobby") string[] hobby, @Param ("user") user user) {
SYSTEM.OUT.PRINTLN (name); League of Legends HD Wallpaper

if (hobby! = null) {
for (String s:hobby) {
System.out.println (s);
}
}

System.out.println ("Name:" +user.getusername ());
System.out.println ("Name:" +user.getpassword ());
}
}
?
? 2. [The code]confirm method corresponds to the HTML page as follows
<%@ page language= "java" contenttype= "text/html; Charset=utf8 "pageencoding=" UTF8 "%>
<! DOCTYPE html>http://www.5idesk.com/s/lol/?
<meta charset= "UTF8"/>
<title>insert title here</title>
<link rel= "stylesheet" type= "Text/css" href= "css/index.css" media= "screen"/>
<body>
<form action= ' USER/CONFIRM/LW ' method= "POST" >
Name: <input name= "User.username" type= "text" value= "/><br/>
Password: <input name= "User.password" type= "text" value= "/><br/>
Tel: <input name= "Phone" type= "text" value= "Liangwei"/><br/>

Hobby:<br/>
Reading <input name= "hobby" type= "checkbox" value= "reading"/>
Music <input name= "hobby" type= "checkbox" value= "Music"/>
Play <input name= "hobby" type= "checkbox" value= "Play"/>
Summer <input name= "hobby" type= "checkbox" value= "Summer"/>

<button type= "Submit" > Login </button>
</form>
</body>
?

My Java MVC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.