您好,欢迎来到筏尚旅游网。
搜索
您的当前位置:首页ajax信息提交

ajax信息提交

来源:筏尚旅游网
Ajax信息提交完整示例

1、页面

<%@ page language=\"java\" import=\"java.util.*\" pageEncoding=\"UTF-8\"%> <%@ tagliburi=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\" %>

信息提交

咨询标题:

*

2、servlet类

packagecom.sdo.cms.zmhd.web.command;

importjava.io.IOException; importjava.io.PrintWriter; importjava.util.ArrayList; importjava.util.List;

importjavax.servlet.ServletException; importjavax.servlet.http.HttpServlet;

importjavax.servlet.http.HttpServletRequest; importjavax.servlet.http.HttpServletResponse;

importnet.sf.json.JSONObject;

public class GetAndPostExampleServlet extends HttpServlet { /** * Constructor of the object. */ publicGetAndPostExampleServlet() { super(); } /** * The doGet method of the servlet.
* * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException { response.setContentType(\"text/html\"); PrintWriter out = response.getWriter(); out .println(\"\"); out.println(\"\"); out.println(\" A Servlet\"); out.println(\" \"); out.print(\" This is \");

out.print(this.getClass()); out.println(\ out.println(\" \"); out.println(\"\"); out.flush(); out.close(); } /** * The doPost method of the servlet.
* * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException { response.setContentType(\"text/xml\"); response.setCharacterEncoding(\"UTF-8\"); String searchKeyWord2=request.getParameter(\"searchKeyWord\"); String searchKeyWord = java.net.URLDecoder.decode(searchKeyWord2, \"utf-8\"); JSONObject ret =new JSONObject(); List list = new ArrayList(); JSONObjectjsonComment=new JSONObject(); jsonComment.put(\"title\\"年月日救助老年人100人,不住退役军官300人...\"); jsonComment.put(\"url\ jsonComment.put(\"id\ jsonComment.put(\"searchKeyWord\ System.out.println(\"评论列表

==========================================\"+ jsonComment.toString()); list.add(jsonComment); ret.put(\"list\ String asd=request.getParameter(\"asd\"); PrintWriter out=response.getWriter(); out.print(ret.toString()); out.close(); } }

3、web配置文件(其中里面字体放大、颜色

有改变的是ajax信息提交需要的部分)

xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\" version=\"2.4\">

csstheme cmsstyle

javax.servlet.jsp.jstl.fmt.localizationContext ApplicationResources

javax.servlet.jsp.jstl.fmt.fallbackLocale en

contextConfigLocation

classpath:/applicationContext-resources.xml classpath:/applicationContext-dao.xml

classpath:/applicationContext-service.xml classpath*:/applicationContext.xml

/WEB-INF/applicationContext*.xml /WEB-INF/xfire-servlet.xml /WEB-INF/security.xml

CacheFilter com.opensymphony.oscache.web.filter.CacheFilter time 300 scope application

CacheFilter /templet_NOSET/*

encodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding UTF-8

forceEncoding true

exportFilter

org.displaytag.filter.ResponseOverrideFilter

gzipFilter

net.sf.ehcache.constructs.web.filter.GzipFilter

staticFilter

com.sinosoft.wcms.webapp.filter.StaticFilter

includes

/scripts/dojo/*,/dwr/*

struts-cleanup

org.apache.struts2.dispatcher.ActionContextCleanUp

struts

org.apache.struts2.dispatcher.FilterDispatcher

encodingFilter *.action

gzipFilter *.css

gzipFilter *.html

gzipFilter *.js

gzipFilter *.jsp

exportFilter *.action

struts-cleanup *.action REQUEST FORWARD

staticFilter /* REQUEST FORWARD

struts *.action REQUEST FORWARD

SDOCMSMonitorForPageView com.sdo.cms.monitor.pageview.SDOCMSPageViewMonitorFilter monitor_file_extname .jsp|.shtml|.html|.htm|/do def_cache_row_count 5 SDOCMSMonitorForPageView /NO_SET/* SDOCMS Authorization com.sdo.cms.security.auth.AdminAuthFilter AdminAuthModuleClass com.sdo.cms.security.auth.SDOCMSAdminAuth

AuthErrPage /sdocmsadmin/purview_err.jsp SessionErrPage /sdocmsadmin/session_timeout.jsp LoginErrPage /sdocmsadmin/login_err.jsp SDOCMS Authorization /sdocmsadmin/* SDOCMS Authorization /sdocmsadminext/* SDOCMS Authorization /do SDOCMSFilter com.sdo.cms.framework.filter.CharacterEncodingFilter encode UTF-8 SDOCMSFilter /*

org.springframework.web.context.ContextLoaderListener

org.springframework.web.util.IntrospectorCleanupListener

org.springframework.web.context.request.RequestContextListener

com.sinosoft.wcms.webapp.listener.StartupListener

com.sinosoft.wcms.webapp.listener.UserCounterListener

dwr-invoker

org.directwebremoting.servlet.DwrServlet

debug true

xfire

org.codehaus.xfire.spring.XFireSpringServlet

UploadProcessService UploadProcessService com.sinosoft.upload.UploadProcessService FileUploadCommandService FileUploadCommandService com.sinosoft.upload.FileUploadCommandService

uploadFile uploadFile com.sinosoft.upload.UploadFileServlet UploadProcessService /uploadProcess FileUploadCommandService /uploadCommand uploadFile /uploadFile

dwr-invoker /dwr/*

xfire

/services/*

ssi

org.apache.catalina.ssi.SSIServlet

buffered 1

debug 0

expires 10

isVirtualWebappRelative 0

outputEncoding UTF-8

inputEncoding UTF-8

4

ssi *.shtml cmscontroller com.sdo.cms.framework.web.CMSController ActionMapping /WEB-INF/config/ActionMapping.properties ExtActionMapping /WEB-INF/config/ActionMappingExt.properties cmscontroller /do adminlogin com.sdo.cms.security.login.AdminLoginServlet AdminLoginModuleClass com.sdo.cms.security.login.SDOCMSAdminLogin isRequestRandCode true overSetCountIsRequestRandCode 3 adminlogin

/AdminLogin adminlogout com.sdo.cms.security.logout.AdminLogoutServlet AdminLogoutModuleClass com.sdo.cms.security.logout.SDOCMSAdminLogout LogoutPage sdocmsadmin/login.jsp adminlogout /AdminLogout SDOCMSCacheToHTML com.sdo.cms.cache.CacheToHTMLServlet SDOCMSCacheToHTML /CacheToHTML counter com.sdo.cms.stat.web.CounterServlet counter /counter ConnectionPoolAdmin org.logicalcobwebs.proxool.admin.servlet.AdminServlet ConnectionPoolAdmin /ConnectionPoolAdmin

sdocmsRss

com.sdo.cms.rss.RssServlet

sdocmsRss /rss.xml configServlet com.sdo.cms.framework.web.ConfigServlet 1 SDOCMSTaskTimer com.sdo.cms.task.web.SDOCMSTaskTimer 2

This is the description of my J2EE component

This is the display name of my J2EE component

GetAndPostExampleServlet

com.sdo.cms.zmhd.web.command.GetAndPostExampleServlet

GetAndPostExampleServlet

/GetAndPostExampleServlet

index.shtml index.html index.htm index.jsp

404

/error/error.jsp 500 /error/error_500.jsp 403 /error/error_403.jsp 400 /error/error_400.jsp com.sdo.cms.framework.web.exception.RuleException /common/rule_error.jsp /sdocms /WEB-INF/tlds/sdocms.tld /sdocmsext /WEB-INF/tlds/sdocms_ext.tld /oscache /WEB-INF/tlds/oscache.tld /tags /WEB-INF/tags/

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- efsc.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务