请求提供一份tomcat servlet api中文api,谢谢!

&&等如何在java web项目中写一个http接口的发布?我用的框架是springmvc,spring,hibernate,想写一个接口供外部调用,但是只让写基于http协议的接口,不用webservice什么的.谢谢了.由编辑于 21:08:041个牛币所有回答列表(10)218.203.170.13&LV9直接返回一个json串就行 用@responesebody&LV26和咱们写普通方法没什么区别,你只要设定好返回的数据格式就行,比如:xml或者是json格式!下面是我写的例子,你可以参考下:1.这个是代码:
package cn.gov.csrc.flight.
import java.util.HashM
import java.util.M
import javax.servlet.http.HttpS
import org.slf4j.L
import org.slf4j.LoggerF
import org.springframework.beans.factory.annotation.A
import org.springframework.stereotype.C
import org.springframework.ui.M
import org.springframework.web.bind.annotation.RequestM
import org.springframework.web.bind.annotation.ResponseB
import cn.gov.csrc.cms.entity.UserE
import cn.gov.csrc.cms.service.UserS
import cn.gov.csrc.cms.util.GlobalC
* 客户端登录
* @version 1.0
* @author zhaoxinguo
* @created 日
@Controller
@RequestMapping(&/u&)
public class ClientController {
private static Logger logger = LoggerFactory
.getLogger(ClientController.class);
private I// 返回值(0失败,1成功)
@Autowired
private UserService userS
* 登录(接口)
* @param model
* @param userName
* @param passWd
* @version 1.0
* @author zhaoxinguo
* @created 日
@RequestMapping(&/login&)
@ResponseBody
public Map&String, Object& login(Model model,HttpSession session,String userName,String passWd,String onlyCode){
UserEntity userEntity = userService.login(userName,passWd);
Map&String, Object& dataMap = new HashMap&String, Object&();
if(userEntity != null){
/*if(userEntity.getOnlyCode().equals(onlyCode)){
dataMap.put(&userId&, userEntity.getUserId());
logger.info(&-----客户端登录成功-----&);
dataMap.put(&flag&, 1);// 成功
logger.info(&-----客户端登录失败-----&);
dataMap.put(&flag&, 0);// 失败
session.setAttribute(GlobalConstants.SESSION_LOGIN_USER,userEntity);// 登录成功
dataMap.put(&userId&, userEntity.getUserId());
logger.info(&-----客户端登录成功-----&);
dataMap.put(&flag&, 1);// 成功
logger.info(&-----客户端登录失败-----&);
dataMap.put(&flag&, 0);// 失败
return dataM
public Integer getFlag() {
public void setFlag(Integer flag) {
this.flag =
2.这个是客户端和服务端接口的交互协议:3.客户端就是通过这设定的地址去访问,如果是外网需要通过ip地址,如果是本地,就直接127.0.0.1就可以了!&LV14说白了就是一个 action,接受参数,返回值json&LV134你要的这个功能本质上是java servlet实现的http接口。可以通过java servlet实现,也可以通过java web mvc框架如struts,springmvc等第三方开源框架来实现。至于部署可以是java的任意web容器,比如tomcat,jetty,resin等。&LV11最基础的一个servlet功能就可以了,看你需求使用get &还是 &post 方式,然后在考虑下数据交互方式,一般来说,现在都是xml或者json字符串,RESTful&&LV2可以使用web service ,返回参数使用json字符串来返回&LV5返回json是最流行的,如果需要返回xml,可以使用一些XML工具来转换。但是需要在用到的model上加xml注解,且不宜解决递归调用。最笨的办法是自己拼xml格式字符串,注意字符编码就行。给你个参考:@RequestMapping(value=&/anonymous/getXml&,produces = &application/ charset=utf-8&)@ResponseBodypublic String getXml(String args,HttpServletResponse response) {& &try {&& &&& String str = getStrXml(args);//这样去获取你的xml字符串,自己去处理,可以传参数&& &&&&& } catch (Exception e) {&& &&& return &出现内部错误。&;//这里打印个错误信息吧&& }}&LV2selvelt 不就好了?完等完等完等完等等等等等相关问答等等完完完等等等完完等完最近浏览&LV5&LV7&LV1&LV2暂无贡献等级暂无贡献等级&LV1&LV1&LV2&LV6扫描二维码关注最代码为好友"/>扫描二维码关注最代码为好友&>&Tomcat中文API文档
Tomcat中文API文档
上传大小:1.06MB
Tomcat 中文 api 文档 帮助
JAXMao汉化
综合评分:4
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有23条
找了个老版本,对照着用~~
可以用 但是版本有点久
版本过低了
happyong001
综合评分:
积分/C币:6
ChuanfengLee
综合评分:
积分/C币:9
lileronglilerong
综合评分:
积分/C币:5
VIP会员动态
热门资源标签
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
Tomcat中文API文档
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
举报的资源分:
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*详细原因:
Tomcat中文API文档这段时间折腾了哈java web应用的压力测试,部署容器是tomcat 7。期间学到了蛮多散碎的知识点,及时梳理总结,构建良好且易理解的知识架构把它们组织起来,以备忘。对web应用开发者来说,我们很关心应用可同时处理的请求数,以及响应时间。应用本身和它运行在其中的web容器是两个很重要的影响因素。对tomcat来说,每一个进来的请求(request)都需要一个线程,直到该请求结束。如果同时进来的请求多于当前可用的请求处理线程数,额外的线程就会被创建,直到到达配置的最大线程数(maxThreads属性值)。如果仍就同时接收到更多请求,这些来不及处理的请求就会在Connector创建的ServerSocket中堆积起来,直到到达最大的配置值(acceptCount属性值)。至此,任何再来的请求将会收到connection refused错误,直到有可用的资源来处理它们。
分析、梳理、组织
这里我们关心的是tomcat能同时处理的请求数和请求响应时间,显然Connector元素的maxThreads和acceptCount属性对其有直接的影响。无论acceptCount值为多少,maxThreads直接决定了实际可同时处理的请求数。而不管maxThreads如何,acceptCount则决定了有多少请求可等待处理。然而,不管是可立即处理请求还是需要放入等待区,都需要tomcat先接受该请求(即接受client的连接请求,建立socketchannel),那么tomcat同时可建立的连接数(maxConnections属性值)也会影响可同时处理的请求数。我们可把tomcat想象成一家医院,你来到医院大厅挂号看病,如果人家接受了,就相当于client和server建立socket连接了。接着你来到相应的科室,科室里每位医生都有一间诊室,这就相当于处理请求的线程;如果所有诊室都有病人,科室的调度护士会让你在科室小厅中耐心等待,直到他们通知你去几号诊室就诊;如果有空闲医生,你就可以立即就诊。有的病人到医院很仓促,结果轮到他挂号或者就诊了,他还在包里翻找病例本和医保卡,如果超过了护士或医生心里可承受的等待时间,他们就会让病人到旁边找去,先服务下位。这种情形跟Connector元素的connectionTimeout属性所起的作用很相像。如果当前连接器(Connector)在接受连接后,等待了指定的时间但仍未接收到requestURI line,就会抛出超时异常。
知识点收集
tomcat 7&的配置参考文档对相关属性已经描述的很详细了,这里把它们收集到一起:
Sets the protocol to handle incoming traffic. The default valueis HTTP/1.1 which uses an auto-switching mechanism to select either a blockingJava based connector or an APR/native based connector. If the PATH (Windows) orLD_LIBRARY_PATH (on most unix systems) environment variables contain the Tomcatnative library, the APR/native connector will be used. If the native librarycannot be found, the blocking Java based connector will be used. Note that theAPR/native connector has different settings for HTTPS than the Java connectors.To use an explicit protocol rather than rely on the auto-switching mechanismdescribed above, the following values may be used:org.apache.coyote.http11.Http11Protocol- blocking Java connectororg.apache.coyote.http11.Http11NioProtocol- non blocking Java connectororg.apache.coyote.http11.Http11AprProtocol- the APR/native connector.Custom implementations may also be used.Take a look at our Connector Comparison chart. The configuration for both Javaconnectors is identical, for http and https.For more information on the APR connector and APR specific SSL settings pleasevisit the APR documentation
maxThreads
The maximum number of request processing threads to be createdby this Connector, which therefore determines the maximum number ofsimultaneous requests that can be handled. If not specified, this attribute isset to 200. If an executor is associated with this connector, this attribute isignored as the connector will execute tasks using the executor rather than aninternal thread pool.
acceptCount
The maximum queue length for incoming connection requests whenall possible request processing threads are in use. Any requests received whenthe queue is full will be refused. The default value is 100.
maxConnections
The maximum number of connections that the server will acceptand process at any given time.&When this number has beenreached, the server will accept, but not process, one further connection. Thisadditional connection be blocked until the number of connections beingprocessed falls below maxConnections at which point the server will startaccepting and processing new connections again. Note that once the limit hasbeen reached, the operating system may still accept connections based on theacceptCount setting.&Thedefault value varies by connector type.&For BIO the default is the value of maxThreads unless an Executor isused in which case the default will be the value of maxThreads from theexecutor. For NIO the default is 10000. For APR/native, the default is 8192.Note that for APR/native on Windows, the configured value will be reduced tothe highest multiple of 1024 that is less than or equal to maxConnections. Thisis done for performance reasons.If set to a value of -1, the maxConnections feature is disabled and connectionsare not counted.
connectionTimeout
The number of milliseconds this&Connector&will&wait,after accepting a connection,&for the request URI lineto be presented. Use a value of -1 to indicate no (i.e.infinite) timeout. The default value is 60000 (i.e. 60 seconds) but note thatthe standard server.xml that ships with Tomcat sets this to 20000 (i.e. 20seconds). Unless&disableUploadTimeout&is set to false, this timeout willalso be used when reading the request body (if any).
进一步分析
tomcat的http connector有三种:bio、nio、apr。从上面的属性描述中可以看出对于不同的connector实现,相同的属性可能会有不同的默认值和不同的处理策略,所以在调整配置前,要先弄清楚各种实现之间的不同,以及当前部署容器使用的是哪种connector。查阅Connector Comparison部分便可获知各种connector实现间的差异。怎样才能知道容器使用的是何种connector实现?启动tomcat后,访问,看到如下信息即可知道使用的是何种connector:我的OS是windows,所以tomcat默认使用的是aprconnector。在linux上,默认使用的是bio connector。与nio相比,bio性能较低。将&TOMCAT_HOME&/conf/server.xml中的如下配置片段:
&Connectorport="8080"protocol="HTTP/1.1"
&&&&&&&&&&&&&& connectionTimeout="20000"
&&&&&&&&&&&&&& redirectPort="8443" /&
&Connectorport="8080"protocol="org.apache.coyote.http11.Http11NioProtocol"
&&&&&&&&&&&&&& connectionTimeout="20000"
&&&&&&&&&&&&&& redirectPort="8443" /&
就可将http connector切换至nio了。更多细节请参考Tomcat Connector运行模式,优化Tomcat运行性能
官网说明:http://tomcat.apache.org/tomcat-7.0-doc/config/http.html
一、最大线程数的设置
Tomcat的server.xml中连接器设置如下
&&&&Connectorport="8080"& maxThreads="150"minSpareThreads="25" maxSpareThreads="75"& enableLookups="false"redirectPort="8443" acceptCount="100"& debug="0"connectionTimeout="20000"& disableUploadTimeout="true"/&&
&tomcat在配置时设置最大线程数,当前线程数超过这个数值时会出错,那么有没有办法捕获到这个错误,从而在client端显示出错信息?
2.&如何加大tomcat连接数在tomcat配置文件server.xml中的&Connector /&配置中,和连接数相关的参数有:minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75acceptCount:允许的最大连接数,应大于等于maxProcessors,默认值为100enableLookups:是否反查域名,取值为:true或false。为了提高处理能力,应设置为falseconnectionTimeout:网络连接超时,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。其中和最大连接数相关的参数为maxProcessors和acceptCount。如果要加大并发连接数,应同时加大这两个参数。web server允许的最大连接数还受制于操作系统的内核参数设置,通常Windows是2000个左右,Linux是1000个左右。tomcat5中的配置示例:&&& &Connector port="8080"&&&&&&&&&&&&&&maxThreads="150" minSpareThreads="25"maxSpareThreads="75"&&&&&&&&&&&&&&enableLookups="false" redirectPort="8443"acceptCount="100"&&&&&&&&&&&&&&debug="0" connectionTimeout="20000"&&&&&&&&&&&&&&&disableUploadTimeout="true" /&对于其他端口的侦听配置,以此类推。
3. tomcat中如何禁止列目录下的文件在{tomcat_home}/conf/web.xml中,把listings参数设置成false即可,如下:
1.&&&init-param&&&
2.&&&param-name&listings&/param-name&&&
3.&&&param-value&false&/param-value&&&
4.&&&/init-param&&&
4.如何加大tomcat可以使用的内存tomcat默认可以使用的内存为128MB,在较大型的应用项目中,这点内存是不够的,需要调大。Unix下,在文件{tomcat_home}/bin/catalina.sh的前面,增加如下设置:JAVA_OPTS='-Xms【初始化内存大小】&-Xmx【可以使用的最大内存】'需要把这个两个参数值调大。例如:JAVA_OPTS='-Xms256m -Xmx512m'表示初始化内存为256MB,可以使用的最大内存为512MB
阅读(...) 评论()豆丁微信公众号
君,已阅读到文档的结尾了呢~~
Tomcat7中文文档(配置说明详解)配置,说明
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
Tomcat7中文文档(配置说明详解)
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='http://www.docin.com/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口&>&Tomcat中文API
Tomcat中文API
上传大小:1.07MB
中文版的Tomcat帮助文档,很好用,需要了解Tomcat配置的,下来学习学习
综合评分:3
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有24条
辣鸡,下了没内容,举报
骗劳资积分
感谢分享,感觉好像有点不全啊
综合评分:
积分/C币:15
综合评分:
积分/C币:3
综合评分:
积分/C币:3
huangkeweiaini
综合评分:
积分/C币:6
VIP会员动态
热门资源标签
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
Tomcat中文API
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
ChuanfengLee
举报的资源分:
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*详细原因:
Tomcat中文API}

我要回帖

更多关于 tomcat api 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信