package net.shopxx.controller.shanghai;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import net.shopxx.controller.admin.BaseController;
import net.shopxx.entity.TruthSearchTeam;
import net.shopxx.service.TruthSearchService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller(“TruthSearchController”)
@RequestMapping(“/truthSearchController”)
public class TruthSearchController extends BaseController {
@Resource(name = “truthSearchServiceImpl”)
private TruthSearchService truthSearchService;
@RequestMapping(value=”/qqqq”,method= RequestMethod.GET)
public String qqqq(){
System.out.println(“1111111111″);
return null;
}
/*
* 查询特搜队内容
*/
@RequestMapping(value=”/query”,method= RequestMethod.GET)
public String query(HttpServletRequest request, ModelMap model){
List<TruthSearchTeam> listTruth = truthSearchService.findList();
StringBuffer detail = new StringBuffer();
detail.append(“,”truthsearchteam”:[“);
for (int i = 0; i < listTruth.size(); i++) {
TruthSearchTeam tst =listTruth.get(i);
if (i > 0){
detail.append(“,”);
}
detail.append(“{“);
detail.append(“”title”:””).append(tst.getTitle()).append(“””);
detail.append(“,”vote”:””).append(tst.getVote()).append(“””);
detail.append(“,”yesNumber”:””).append(tst.getYesNumber()).append(“””);
detail.append(“,”noNumber”:””).append(tst.getNoNumber()).append(“””);
detail.append(“,”ipAddress”:””).append(tst.getIpAddress()).append(“””);
// detail.append(“,”beginDate”:””).append(AppUtils.date2String(tst.getBeginDate())).append(“””);
// detail.append(“,”endDate”:””).append(AppUtils.date2String(tst.getEndDate())).append(“””);
detail.append(“}”);
}
detail.append(“]”);
StringBuffer result = new StringBuffer();
result.append(“{“result_code”:”0″”).append(detail).append(“}”);
return result.toString();
}
/*
* 投票
*/
@RequestMapping(value=”/vote”,method= RequestMethod.POST)
public String vote( HttpServletRequest request, ModelMap model){
long id = Long.parseLong(request.getParameter(“id”));
String vote = request.getParameter(“vote”);
return truthSearchService.vote(id, vote)+””;
}
}
浏览器地址:
http://127.0.0.1:8080/sslj8/truthSearchController/query.jhtml
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import net.shopxx.controller.admin.BaseController;
import net.shopxx.entity.TruthSearchTeam;
import net.shopxx.service.TruthSearchService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller(“TruthSearchController”)
@RequestMapping(“/truthSearchController”)
public class TruthSearchController extends BaseController {
@Resource(name = “truthSearchServiceImpl”)
private TruthSearchService truthSearchService;
@RequestMapping(value=”/qqqq”,method= RequestMethod.GET)
public String qqqq(){
System.out.println(“1111111111″);
return null;
}
/*
* 查询特搜队内容
*/
@RequestMapping(value=”/query”,method= RequestMethod.GET)
public String query(HttpServletRequest request, ModelMap model){
List<TruthSearchTeam> listTruth = truthSearchService.findList();
StringBuffer detail = new StringBuffer();
detail.append(“,”truthsearchteam”:[“);
for (int i = 0; i < listTruth.size(); i++) {
TruthSearchTeam tst =listTruth.get(i);
if (i > 0){
detail.append(“,”);
}
detail.append(“{“);
detail.append(“”title”:””).append(tst.getTitle()).append(“””);
detail.append(“,”vote”:””).append(tst.getVote()).append(“””);
detail.append(“,”yesNumber”:””).append(tst.getYesNumber()).append(“””);
detail.append(“,”noNumber”:””).append(tst.getNoNumber()).append(“””);
detail.append(“,”ipAddress”:””).append(tst.getIpAddress()).append(“””);
// detail.append(“,”beginDate”:””).append(AppUtils.date2String(tst.getBeginDate())).append(“””);
// detail.append(“,”endDate”:””).append(AppUtils.date2String(tst.getEndDate())).append(“””);
detail.append(“}”);
}
detail.append(“]”);
StringBuffer result = new StringBuffer();
result.append(“{“result_code”:”0″”).append(detail).append(“}”);
return result.toString();
}
/*
* 投票
*/
@RequestMapping(value=”/vote”,method= RequestMethod.POST)
public String vote( HttpServletRequest request, ModelMap model){
long id = Long.parseLong(request.getParameter(“id”));
String vote = request.getParameter(“vote”);
return truthSearchService.vote(id, vote)+””;
}
}
浏览器地址:
http://127.0.0.1:8080/sslj8/truthSearchController/query.jhtml
解决方案
5
你的truthSearchController里面有query 没有query.jhtml
5
10
1.重新clean下项目,发布,重启tomcat试试
2.后台有没有报错
3.同一个controller中其他的方法能访问吗(例如:http://127.0.0.1:8080/sslj8/truthSearchController/qqqq.jhtml)
4.是不是断点加的位置不对
5.跟拦截器有没有关系
….
这渣渣水平只能想这么多了
2.后台有没有报错
3.同一个controller中其他的方法能访问吗(例如:http://127.0.0.1:8080/sslj8/truthSearchController/qqqq.jhtml)
4.是不是断点加的位置不对
5.跟拦截器有没有关系
….
这渣渣水平只能想这么多了