One, single parameter:
PublicList<xxbean>getxxbeanlist (String xxcode); <SelectId="getxxxbeanlist"Parametertype="java.lang.String"Resulttype="Xxbean">Selectt.* fromTableName TwhereT.id=#{id}</Select>where the method name and ID are the same, the parameter names in #{} are the names of the parameters in the method, and I use the short name that Xxxbean uses.SelectThe field list is consistent with the name of the attribute in the bean, and if it is inconsistent, you can use the asTo add.
Two, multi-parameter:
Public List<xxxbean> getxxxbeanlist (String xxid, String xxcode); <select id="getxxxbeanlist " resulttype="xxbean" > Selectfromwhere id = #{0} and name = #{1} /c15></Select> because it is a multi-parameter then you can not use ParameterType, instead #{index} is the first number of the index, the index starting from 0
three, map package multi-parameter:
public list<xxxbean> Getxxxbeanlist (HashMap map); <select id= " getxxxbeanlist parametertype=" hashmap " Resulttype= " xxbean " > select Field ... from XXX where Id=#{xxid} code = #{xxcode} < /select >
Iv. List Package in:
PublicList<xxxbean> Getxxxbeanlist (list<string>list); <SelectId="getxxxbeanlist"Resulttype="Xxbean">SelectField... fromXxxwhereIdinch<foreachitem="Item"index="Index"collection="List"open="("Separator=","Close=")">#{item}</foreach> </Select>foreachThe final effect is the Select field ... fromXxxwhereIdinch('1','2','3','4')
five, multi-parameter transmission of the annotated mode is shown:
Example: PublicAddrinfo getaddrinfo (@Param ("Corpid")intCorpid, @Param ("Addrid")intAddrid); The XML configuration is written like this:<SelectId="getaddrinfo"resultmap="Com.xxx.xxx.AddrInfo">SELECT*From Addr__infowhereAddr_id=#{addrid} and Corp_id=#{corpid}</Select>previously in<Select> sentence to take ParameterType, now you can not write this.
Six, SelectList () can only pass one parameter, but the actual required parameter must contain both the string type and the list type when it is processed:
Put the parameters in the map and then take out the list traversal in the map. As follows:
New Arraylist<string>(); MapNew hashmap<string, object>(); List.add ("1");
List.add ("2");
map.put ( list ", list); // URL ID map.put ( SiteTag , " 0 ); // URL type
Public List<sysweb> Getsysinfo (map<string, object> map2) { return getsqlsession (). SelectList ( " Sysweb.getsysinfo " , MAP2);}
<SelectId="Getsysinfo"Parametertype="Java.util.Map"Resulttype="Sysweb">SelectT.syssiteid, T.sitename, T1.mznum asSitetagnum, T1.mzname asSiteTag, T.url, T.iconpath fromTd_web_syssite T left join Td_mz_mzdy T1 on T1.mznum= T.sitetag and T1.mztype =TenWHERE T.sitetag=#{sitetag} and T.syssiteid notinch<foreachcollection="List"item="Item"index="Index"open="("Close=")"Separator=",">#{item}</foreach> </Select>
MyBatis the problem of passing in multiple parameters