package demo.spring.mvc.common;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.Tag;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
public class ViewIPTag implements Tag{
private PageContext pageContext;
@Override
public int doEndTag() throws JspException {
// HttpServletRequest request = (HttpServletRequest)pageContext.getRequest(); //获取request
HttpServletRequest request2 = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
// JspWriter out = pageContext.getOut(); //获取out</span>
HttpServletResponse response = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse();
String ip = request2.getRemoteAddr(); //通过request获取客户机的ip
try {
PrintWriter out2=response.getWriter();
out2.write("<div style='color:red' position:relation>"+ip+"</div>");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
/*try {
out.write(ip); //写到浏览器
} catch (IOException e) {
throw new RuntimeException(e);
} */
return 0;
}
@Override
public int doStartTag() throws JspException {
// TODO Auto-generated method stub
return 0;
}
@Override
public Tag getParent() {
// TODO Auto-generated method stub
return null;
}
@Override
public void release() {
// TODO Auto-generated method stub
}
@Override
public void setPageContext(PageContext arg0) {
// TODO Auto-generated method stub
}
@Override
public void setParent(Tag arg0) {
// TODO Auto-generated method stub
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
springMVC+mybatis
共64个文件
xml:14个
java:10个
class:10个
需积分: 10 32 下载量 166 浏览量
2018-05-29
21:34:47
上传
评论
收藏 163KB RAR 举报
温馨提示
springMVC+spring4+mybatis的例子,方便易懂,亲测可用。
资源详情
资源评论
资源推荐
收起资源包目录
springMVC+mybatis.rar (64个子文件)
mvc
.project 1KB
logs
ssm.log 3KB
src
test
java
demo
spring
mvc
AppTest.java 287B
main
webapp
WEB-INF
springmvc-servlet.xml 2KB
jsp
a.jsp 965B
js
b.js 36B
applicationContext.xml 3KB
classes
applicationContext.xml 3KB
mapper
StudentMapper.xml 2KB
config
mysql.properties 82B
log4j.properties 1KB
springMybatis.xml 2KB
lib
js
a.js 95B
jquery.min.js 93KB
jquery-1.7.2.js 247KB
jquery-1.7.2.min.js 93KB
com
a.tld 758B
com.jsp 490B
web.xml 1KB
common
common.jsp 412B
common.js 120B
index.jsp 365B
js
aa.js 37B
bb.js 38B
META-INF
MANIFEST.MF 39B
resources
applicationContext.xml 3KB
mapper
StudentMapper.xml 2KB
config
mysql.properties 82B
log4j.properties 1KB
springMybatis.xml 2KB
java
demo
spring
mvc
common
ViewIPTag.java 2KB
service
StudentService.java 387B
impl
StudentServiceImpl.java 1KB
App.java 178B
domain
Student.java 570B
controller
StudentAction.java 644B
TestAction.java 894B
IDao
StudentMapper.java 380B
test
Test.java 454B
target
classes
applicationContext.xml 3KB
mapper
StudentMapper.xml 2KB
demo
spring
mvc
common
ViewIPTag.class 2KB
service
impl
StudentServiceImpl.class 1KB
StudentService.class 420B
domain
Student.class 1KB
controller
StudentAction.class 1KB
TestAction.class 1KB
IDao
StudentMapper.class 415B
App.class 545B
test
Test.class 868B
config
mysql.properties 82B
log4j.properties 1KB
springMybatis.xml 2KB
test-classes
demo
spring
mvc
AppTest.class 477B
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 219B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 430B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.core.resources.prefs 155B
org.eclipse.wst.common.component 700B
.jsdtscope 565B
pom.xml 6KB
.classpath 1KB
共 64 条
- 1
东家庄
- 粉丝: 6
- 资源: 20
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0