GWT整合JSP案例
来源:互联网 发布:圣诞节怎么过知乎 编辑:程序博客网 时间:2024/06/06 08:36
目录结构:
以下是源码:
package com.app.client;import com.google.gwt.core.client.EntryPoint;import com.google.gwt.event.dom.client.ClickEvent;import com.google.gwt.event.dom.client.ClickHandler;import com.google.gwt.user.client.Window;import com.google.gwt.user.client.ui.Button;import com.google.gwt.user.client.ui.HorizontalPanel;import com.google.gwt.user.client.ui.RootPanel;import com.google.gwt.user.client.ui.TextBox;/** * Entry point classes define <code>onModuleLoad()</code>. */public class Test implements EntryPoint {/** * This is the entry point method. */public void onModuleLoad() {HorizontalPanel horPanel = new HorizontalPanel();final TextBox titleBox = new TextBox();Button btn = new Button("Send");btn.addClickHandler(new ClickHandler() {@Overridepublic void onClick(ClickEvent event) {String protocol = Window.Location.getProtocol();String host = Window.Location.getHost();Window.open(protocol + "//" + host + "/test/print?text="+titleBox.getValue(), "print", null);}});String protocol = Window.Location.getProtocol();String host = Window.Location.getHost();System.out.println(protocol);System.out.println(host);horPanel.add(titleBox);horPanel.add(btn);RootPanel.get().add(horPanel);}}
package com.app.print;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class PrintServlet extends HttpServlet {private static final long serialVersionUID = 1L;@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {doPost(req, resp);}@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {req.setCharacterEncoding("UTF-8");resp.setCharacterEncoding("UTF-8");req.setAttribute("text", req.getParameter("text"));req.getRequestDispatcher("/print.jsp").forward(req, resp);}}
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css"></style></head><body><h1>Text: <%= request.getAttribute("text") %> </h1></body></html>
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"> <!-- Servlets --> <servlet> <servlet-name>printservlet</servlet-name> <servlet-class>com.app.print.PrintServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>printservlet</servlet-name> <url-pattern>/test/print</url-pattern> </servlet-mapping> <!-- Default page to serve --> <welcome-file-list> <welcome-file>Test.html</welcome-file> </welcome-file-list></web-app>
- GWT整合JSP案例
- jsp整合mybatis案例
- gwt整合
- gwt整合
- MyEclipse整合GWT
- GWT整合Struts2
- GWT + Spring MVC + JPA整合
- GWT、Spring、Strtus、Hibernate整合
- 整合GWT与Jetty Continuations
- gwt+spring+hibernate的整合
- Gxt和GWT整合小示例
- JSP整合
- GWT
- GWT
- GWT
- GWT
- gwt
- GWT
- 回忆在iOS开发中常常使用的工具
- JS 父窗体与子窗体调用总结
- mkfs.ubifs和ubinize两个工具后,就可以制作UBIFS镜像了
- java中static{}语句块详解
- 解读struts.xml文件自动加载方法的方式以及service层的自动注入
- GWT整合JSP案例
- ORM中数据类型的无缝转换
- png图片里加自定义数据
- Hadoop小结
- 微信公众帐号开发教程第5篇-各种消息的接收与响应
- 游戏备案流程与所需材料是什么?
- 黑马程序员-----java内部类总结*
- android ViewFlipper的使用
- 简单工厂,工厂方法和抽象工厂的区别总结