Servlet implementation class NewsListServlet

 package com.wangjialin.server.xml;

 import java.io.IOException;
import java.util.List; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.wangjialin.server.domain.News;
import com.wangjialin.server.service.XMLService;
import com.wangjialin.server.service.implement.XMLServiceBean; /**
* Servlet implementation class NewsListServlet
*/
public class ServletForXML extends HttpServlet { private static final long serialVersionUID = 1L;
private XMLService newsService = new XMLServiceBean(); protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
} protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<News> newes = newsService.getLastNews();//获取最新的视频资讯 request.setAttribute("newes", newes);
request.getRequestDispatcher("/WEB-INF/page/news.jsp").forward(request, response);
} }

XMLServiceBean

 package com.wangjialin.server.service.implement;

 import java.util.ArrayList;
import java.util.List; import com.wangjialin.server.domain.News;
import com.wangjialin.server.service.XMLService; public class XMLServiceBean implements XMLService {
/**
* 获取最新的视频资讯
* @return
*/
public List<News> getLastNews(){ List<News> newes = new ArrayList<News>();
newes.add(new News(10, "wangjialin", 20));
newes.add(new News(45, "jialingege", 10));
newes.add(new News(89, "android", 50));
return newes;
}
}

XMLService

 package com.wangjialin.server.service;

 import java.util.List;

 import com.wangjialin.server.domain.News;

 public interface XMLService {

     /**
* 获取最新的视频资讯
* @return
*/
public List<News> getLastNews(); }

News.java

 package com.wangjialin.server.domain;

 public class News {

     private Integer id;
private String title;
private Integer timelength; public News(Integer id, String title, Integer timelength) {
this.id = id;
this.title = title;
this.timelength = timelength;
} public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getTitle() {
return title;
} public void setTitle(String title) {
this.title = title;
} public Integer getTimelength() {
return timelength;
} public void setTimelength(Integer timelength) {
this.timelength = timelength;
} }

news.jsp

 <%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><?xml version="1.0" encoding="UTF-8"?>
<newslist>
<c:forEach items="${newes}" var="news">
<news id="${news.id}">
<title>${news.title}</title>
<timelength>${news.timelength}</timelength>
</news>
</c:forEach>
</newslist>

Android 开发服务类 01_ServletForXML的更多相关文章

  1. Android 开发服务类 05_ ApkPatchDemo

    APP 增量更新服务端[https://github.com/cundong/SmartAppUpdates] import com.cundong.common.Constants; import ...

  2. Android 开发服务类 04_ServletForPOSTMethod

    ServletForPOSTMethod 业务类 package com.wangjialin.internet.servlet; import java.io.IOException; import ...

  3. Android 开发服务类 02_NewsListServlet

    Servlet implementation class NewsListServlet package com.wangjialin.server.xml; import java.io.IOExc ...

  4. Android 开发服务类 03_ServletForGETMethod

    接收并处理用户通过 GET 方式上传的数据,一般小于 2K,并且安全性要求不高. package com.wangjialin.internet.servlet; import java.io.IOE ...

  5. Android开发工具类

    7种无须编程的DIY开发工具 你知道几个? 现如今,各种DIY开发工具不断的出现,使得企业和个人在短短几分钟内就能完成应用的创建和发布,大大节省了在时间和资金上的投入.此外,DIY工 具的出现,也帮助 ...

  6. Android开发——Context类的各种细节问题

    0. 前言   Context相信所有的Android开发人员基本上每天都在接触,因为它太常见了.但实际上Context有太多小的细节并不被大家所关注,那么今天我们就来学习一下那些你所不知道的细节. ...

  7. Android 开发工具类 35_PatchUtils

    增量更新工具类[https://github.com/cundong/SmartAppUpdates] import java.io.File; import android.app.Activity ...

  8. Android 开发 Camera类的拍照与录像

    前言 在开发Android应用的时候,如果需要调用摄像头拍照或者录像,除了通过Intent调用系统现有相机应用进行拍照录像之外,还可以通过直接调用Camera硬件去去获取摄像头进行拍照录像的操作.本篇 ...

  9. Android 开发工具类 27_多线程下载大文件

    多线程下载大文件时序图 FileDownloader.java package com.wangjialin.internet.service.downloader; import java.io.F ...

随机推荐

  1. Ubuntu安装教程(双系统)

    经常要重装还不如写个安装教程省的每次都要查 Ubuntu安装教程: win7下安装Linux实现双系统全攻略:https://jingyan.baidu.com/article/c275f6bacc3 ...

  2. (线段树模板)A Simple Problem with Integers --POJ--3468

    链接: http://poj.org/problem?id=3468 代码: #include<stdio.h> #include<algorithm> #include< ...

  3. IDEA14添加SVN

    今天升级IDEA14,发现SVN变了,折腾了好一会才搞好.记录一下,希望其他人能少走弯路.主要是IDEA14的svn是用命令行工具进行操作,这样对以后SVN的兼容性也会好很多,这个在他们官方的博客上也 ...

  4. hdu 4994 前后有序Nim游戏

    http://acm.hdu.edu.cn/showproblem.php?pid=4994 Nim游戏变成从前往后有序的,谁是winner? 如果当前堆数目为1,玩家没有选择,只能取走.遇到到不为1 ...

  5. Spring 注入集合类型

    定义了一个类: @Service public class StringTest implements CachedRowSet,SortedSet<String>,Cloneable @ ...

  6. EBS 11i升级R12

     http://blog.csdn.net/y657356105/article/details/8181081 概述 从EBS 11i升级至R12,总的来说更变较大的就是多OU访问(MOAC)和表视 ...

  7. Simple Package Tool 学习

    Simple Package Tool 学习   1.getattr内置函数 getattr(object, name[, default]) python Packages.py install - ...

  8. efcore操作mysql,出现System.InvalidOperationException:“No coercion operator is defined between types 'System.Int16' and 'System.Boolean'.”

    这个恶心的问题,只需要把EF的依赖换成 Pomelo.EntityFrameworkCore.MySql 库即可解决

  9. hdu A Magic Lamp

    http://acm.hdu.edu.cn/showproblem.php?pid=3183 A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)   ...

  10. ko内核模块文件以及载入模块命令modprobe insmod

    原文链接:https://blog.csdn.net/evenness/article/details/7655921?utm_source=blogxgwz5 modprobe: Load modu ...