angular-select显示数组案例

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
{{x.country}}选择的数据是:{{selectedvalue}}
__________________________________________________
  • {{ x.name + ' ' + x.country }}
//下面是servlet发送数据package com.servlet;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import java.util.List;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import net.sf.json.JSONArray;/** * Servlet implementation class JsonServlet */@WebServlet("/JsonServlet")public class JsonServlet extends HttpServlet {private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {Country c1 = new Country("name1","country1");Country c2 = new Country("name2","country2");Country c3 = new Country("name4","country4");Country c4 = new Country("name3","country3");List list = new ArrayList();list.add(c1);list.add(c2);list.add(c3);list.add(c4);JSONArray array = JSONArray.fromObject(list);System.out.println(array.toString());PrintWriter out = response.getWriter();out.write(array.toString());// request.getSession().setAttribute("country",array.toString());// response.sendRedirect(request.getContextPath()+"/json.jsp");}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {Country c1 = new Country("name5","country5");Country c2 = new Country("name6","country6");Country c3 = new Country("name7","country7");Country c4 = new Country("name8","country8");List list = new ArrayList();list.add(c1);list.add(c2);list.add(c3);list.add(c4);JSONArray array = JSONArray.fromObject(list);System.out.println(array.toString());PrintWriter out = response.getWriter();out.write(array.toString());// request.getSession().setAttribute("country",array.toString());// response.sendRedirect(request.getContextPath()+"/json.jsp");}}

你可能感兴趣的:(angularjs)