Dao类
@Select("<script> SELECT * FROM merchant WHERE 1=1 <if test=\"uname!= null \"> AND uname =#{uname} if> <if test=\"state!= null \"> AND state =#{state} if> script>")
// List<Merchant> SelectAll(Map map);
Service类
package com.fruitsMgr.Service;
import java.util.List;
import com.fruitsMgr.pojo.Merchant;
public interface MerchantService {
//登录
int login(String uname,String pwd);
//注册
boolean addMerchant(Merchant m);
//修改密码
boolean updatePwd(String uname,String OldPwd,String NewsPwd);
List getUserss(String uname,String state) ;
//修改状态
boolean updateState(int merchantid);
//显示全部用户
List getAllMerchant() ;
Serviceimpl类
package com.fruitsMgr.Serviceimpl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fruitsMgr.Service.MerchantService;
import com.fruitsMgr.Util.MyBatisUtils;
import com.fruitsMgr.inter.IMerchantDao;
import com.fruitsMgr.pojo.Merchant;
@Service
public class MerchantServiceimpl extends MyBatisUtils implements MerchantService {
@Autowired
private IMerchantDao mh;
**Controll类头部**
```java
package com.fruitsMgr.Controll;
import java.io.IOException;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.fruitsMgr.Service.MerchantService;
import com.fruitsMgr.pojo.Merchant;
@Controller
@RequestMapping("/merchant")
public class MerchantControll {
@Autowired
private MerchantService ms;
public MerchantService getMs() {
return ms;
}
public void setMs(MerchantService ms) {
this.ms = ms;
}
Controll类
@ResponseBody
@RequestMapping(value="/getMerAllchant")
public String getMerAllchant()
{
System.out.println(1);
List lay=ms.getAllMerchant();
String json="";
try {
ObjectMapper mapper=new ObjectMapper();
json=mapper.writeValueAsString(lay);
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(json.toString());
return json;
}
这个是我在C站上面找的,然后报错了,这个是需要配置什么吗
实现SSM注解方式的动态sql
前面的script都包起来了,最后的script是怎么个意思;
不用写script吧,我看看你的报错信息是什么