【相關(guān)視頻推薦:ajax視頻教程】
成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),朝陽企業(yè)網(wǎng)站建設(shè),朝陽品牌網(wǎng)站建設(shè),網(wǎng)站定制,朝陽網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,朝陽網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。環(huán)境:eclipse+struts
要實現(xiàn)的效果:點擊按鈕提交數(shù)據(jù)到后臺之后回到前臺顯示出來數(shù)據(jù)
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>Insert title here
struts.xml
index.jsp
Test.java
package com.action; import java.io.PrintWriter; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class Test extends ActionSupport { @Override public String execute() throws Exception { // TODO Auto-generated method stub HttpServletRequest request = org.apache.struts2.ServletActionContext.getRequest(); HttpServletResponse response = ServletActionContext.getResponse(); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); out.write(request.getParameter("username")); out.flush(); out.close(); return SUCCESS; } }
相關(guān)學(xué)習(xí)推薦:java基礎(chǔ)教程