IE下当jsp传值时URL中包含中文跳转时找不到页面

IE下当jsp传值时URL中包含中文跳转时找不到页面,然后后台报错:

 Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

图片说明
急急急啊,求教大神们!!!

1个回答

400 请求出错
由于语法格式有误,服务器无法理解此请求。不作修改,客户程序就无法重复此请求。

很明显你代码写的有问题。。。

tianguozhiya
去你大爷的昵称已存在 是因为没有对URL中的中文做转义,然后在ie下又对URL中的特殊符号以及中文有要求,所以报错了,已经解决
接近 3 年之前 回复
tianguozhiya
去你大爷的昵称已存在 是因为没有对URL中的中文做转义,然后在ie下又对URL中的特殊符号以及中文有要求,所以报错了,已经解决
接近 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
jsp中 <jsp:include> 中使用绝对路径的问题
这里我主要是在讲自己在解决这个问题过程中对具体问题的理解,有可能前后矛盾,因为我是把我的认识过程顺序的说出来,想让大家帮忙指出不对的地方。 因为问题解决了,可是道理认识歪了,后患无穷啊。特别是对我这个非科班出身的2手程序员。 PS:不知道怎么在入门讨论中发普通的帖子。提示我没积分了,那就发个提问帖,本来这贴目的其实也是在“提问” ------------------------------------------------------------------------------------------------ 从一个需求说起(自己之前对WEB项目中的相对路径和绝对路径有一些了解) 需求是这样的,要在JSP中应用<jsp:include>标签引入一个公用的页面 [quote]<jsp:include page="../templates/header.jsp"></jsp:include>[/quote] 就是写类似上面的一段语句。 不过这段代码的要求是要在本项目中任意一个JSP文件中都管用的, 说白了就是在项目现有的任意一个页面中加入相同的这样一段代码,都能达到引入某个固定页面的效果。 所以这里不能用相对路径。原因我自己总结了两条: 1,没办法保证对页面的访问方式,是直接访问还是通过其它请求跳转访问,访问的URL不确定,相对路径达不到要求。 2,项目中的页面本身目录结构不可能都正好在一个文件夹中。 所以自然想到用绝对路径,所以开始我是这样写的 [quote] <jsp:include page="<%=request.getContextPath()%>/templates/header.jsp"></jsp:include> [/quote] 这么写,当时没多想,就是直接仿照引入其它图片CSS什么的写的。比如 [code="java"]<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/xx.css"/>[/code] 页面报错,之后想想,TOMCAT(我用的是TOMCAT)解析JSP时,对<jsp:include>的解析有别于其它。 [code="java"] <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/xx.css"/> 只是按照基本规则简单的解析为几个输出语句: out.write("<link rel=\"stylesheet\" type=\"text/css\" href=\""); out.print(request.getContextPath()); out.write("/css/xx.css\"/>\r\n"); [/code] 而对<jsp:include>的解析却要特殊一些,它没有直接输出字符串的语句,而是这样的: [quote] <jsp:include page="../templates/header.jsp"></jsp:include> 被解析为: org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "../templates/header.jsp", out, false); [/quote] 自己简单总结了下,JSP中对<jsp:include>标签的解析就是直接生成上面那样一条语句,而page属性的值直接作为方法的参数,也因为这个,所以page的值不能这样写page="<%=request.getContextPath()%>/templates/header.jsp"。之所以不能这样写(自己认为)也没什么道理需要讲,说白了就是JSP没这样的语法。 也就是说对于<jsp:include>标签的page属性的值,只能是一个写死的字符串。否则在JSP级别上就会有语法错误,结果是容器连对应的JAVA文件都没办法生成,更不要说真正用到的CLASS文件了。 综上,所以页面会报错。 那么这里怎么用绝对路径呢?或者说 org.apache.jasper.runtime.JspRuntimeLibrary.include方法是怎么用的? GOOGLE了下 也没找到什么对自己有用的(自己看得懂的)东西。 又尝试了其它几种形式 [code="java"]<jsp:include page="/项目名/templates/header.jsp"></jsp:include> 解析为 org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "/项目名/templates/header.jsp", out, false);[/code] [code="java"]<jsp:include page="http://localhost:8080/项目名/templates/header.jsp"></jsp:include> 解析为 org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "http://localhost:8080/项目名/templates/header.jsp", out, false);[/code] 以上2种尝试,对于标签的解析结果符合之前我的结论,JSP顺利的生成了最后的CLASS文件。 可是访问时继续报错。 "/项目名/templates/header.jsp”“http://localhost:8080/项目名/templates/header.jsp” 这两种路径就是WEB项目中绝对路径的用法。 而连生成的JAVA文件中,方法的参数也都已经成功把这2个参数带入了,可是仍报错。 显然org.apache.jasper.runtime.JspRuntimeLibrary.include方法对路径的解析与IE不同。 人多力量大,请经理来看看,在报错信息中发现了问题。 之前2中用法: <jsp:include page=" [color=red]/项目名/templates/header.jsp[/color]"></jsp:include> 报的错为 org.apache.jasper.JasperException: javax.servlet.ServletException: File &quot; [color=red]/项目名/templates/header.jsp[/color]&quot; not found 提示找不到的页面就是参数给出的页面"/项目名/templates/header.jsp" 这个去掉开头的“/”后面的路径应该绝对没问题,除非这个“/”不代表服务器的根目录(服务器地址) 下面 <jsp:include page=" [color=green]http://localhost:8080/项目名/templates/header.jsp[/color]"> 报的错为 org.apache.jasper.JasperException: javax.servlet.ServletException: File &quot; [color=green]/templates/http:/localhost:8080/项目名/templates/header.jsp[/color]&quot; not found 提示找不到的页面比参数在前面多出了一段 /templates/ 就是说这里并没有因为参数以“http://”开头而给予"特殊待遇",只是把它当成了一段普通的字符串,同时因为不是以“/”开头的而被当成了相对路径处理,并在前面补充上了"/templates/" 那个如果是这样,这个 "/templates/"就应该是自身所在的位置,而按此推理,这个“/”代表了??? 又实验了下 <jsp:include page=" [color=red]../templates/一个不存在的页面[/color]"></jsp:include> 报错为 org.apache.jasper.JasperException: javax.servlet.ServletException: File &quot; [color=red]/templates/一个不存在的页面[/color]&quot; not found [size=x-small][color=orange]结论[/color][/size] 观察了下,想了想,知道了,原来我饶了一个大圈,问题其实很简单: 总结了下,JSP中<jsp:include>标签的应用: 1,不支持<%= %>等动态的语法,特别是page属性的值,只能是一个写死的字符串(刚听说,其实也有自己本身的一些特殊语法,以后再学) 2,对于引入页面的路径问题,也可以常用"绝对路径"和"相对路径"两种应用方式。 绝对路径就是以“/”开头的路径,其它的包括以“http://”开头的都是相对路径,可应用“./”“../”等 相对路径 没什么好说的。强调一点,这里的相对路径也是相对于访问页面的URL的路径,本质上与页面文件在项目中的存储位置没直接关系,所以这里用相对路径时也存在由于访问URL不确定带来的问题(是不是这样呢?如文章开头说的,这里都是我自己的结论)。 主要是绝对路径的问题: 我们知道大部分情况下写在页面(不管静态还是动态)里并输出到IE中的路径都是由IE来解析的,以“/”开头的绝对路径 这个“/”代表的是服务器的根目录:比如访问URL为 http://localhost:8080/项目名/templates/template.jsp 那么“/”代表的就是 "http://localhost:8080/" 而并不带有项目名信息。 而<jsp:include>引入页面的过程,是在服务器运行向IE输出数据的过程中由JAVA程序调用执行,路径也当然由JAVA程序来解析,此时以"/"开头的绝对路径中的“/” 代表的已经是本项目的根目录了。 比如 URL为 http://localhost:8080/项目名/templates/template.jsp 那么“/”代表的就是 "http://localhost:8080/项目名/"。已经带有了项目名信息。 同时,也不用像引入JS CSS文件那样在路径前加上 <%=request.getContextPath()%> 来解决项目名本身修改的问题了。只需一个“/”就什么也不用管了。 如上所述: 需求需要的这段代码其实很简单 [quote]<jsp:include page="/templates/header.jsp"></jsp:include> [/quote] 需要被任意位置的页面引入的页面 存放在项目根目录下的templates目录下 [b]问题补充:[/b] 多谢,特别是1楼说的第一点(1.jsp:include支持<%=%>语句。),使自己有动力学一学 jsp:include 中 <%=%>到底怎么用 做了个测试: 测试1: [code="java"] <% String pageURL = "header.jsp"; %><%=pageURL%><jsp:include page= [color=red]"/templates/<%=pageURL%>" [/color]></jsp:include> 被解析成了这样一段JAVA代码 String pageURL = "header.jsp"; out.print(pageURL); org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, [color=red]"/templates/<%=pageURL%>" [/color], out, false); [/code] 这个跟我之前说的一样, page="/templates/<%=pageURL%>" 引号中的值被当成了一个字符串作为对应方法的参数,而没有对 <%=%>有什么特殊的处理。 测试2: [code="java"] <% String pageURL = "/templates/header.jsp"; %><%=pageURL%><jsp:include page= [color=red]"<%=pageURL%>" [/color]></jsp:include> 解析结果 String pageURL = "/templates/header.jsp"; out.print(pageURL); org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, [color=red]pageURL[/color], out, false);[/code] 哈哈,这次 解析的时候 成功的将 page="<%=pageURL%>" 中的pageURL当成一个变量作为对应方法的参数了 我得到的结论就是: 首先就是一楼朋友说的, 在<jsp:include>中是支持<%=%>的。 具体的语法就是,在给page属性赋值的时候,如果想应用<%=%>。那么一定不要另外添加其它字符,这样就会将<%=%>中的变量成功解析为对应方法的参数。 否则会将引号中的内容当成一个死的字符串作为参数。
谷歌和IE兼容问题,IE登录进入不了新页面
代码在谷歌可以登录成功,在IE浏览器,点击登录没反应,调试时进入登录方法执行成功,就是不跳转到新的页面,代码如下: (登录方法),求指点 function check(){ var a = $("#username").val(); var b = $("#password").val(); if(a==''){ // $.messager.alert('系统提示', '用户名不能为空', 'info'); $("#msg").html("用户名不能为空"); $("#username").focus(); return false; } else if(b==""){ $("#password").focus(); $("#msg").html("密码不能为空"); return false; } $.ajax({ url:'<%=path %>/sysLoginController/login.do', type:'post', data:{'username':a,'password':b}, success:function(data){ var json=eval('('+data+')'); console.info(json); if(json.status == '1'){ window.location.href="<%=path %>/index.jsp"; }else if(json.status == '3'){ $("#msg").html("用户名不存在,请重新输入"); return; }else if(json.status == '2'){ $("#msg").html("密码错误,请重新输入"); return; }else{ $("#msg").html("系统异常,请联系管理员!"); } } }); },
登陆界面的用户名id怎么传到后面让其他页面可以用?我改的不起作用
login.jsp <%@page import="org.apache.tomcat.util.descriptor.web.LoginConfig"%> <%@page import="com.sun.java.swing.plaf.windows.resources.windows"%> <%@page import="javax.servlet.jsp.tagext.TryCatchFinally"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %> <!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"> <title>用户登录</title> </head> <body> <!-- 统一编码 --> <% request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); %> <!-- 连接数据库 --> <%! String driver="com.mysql.jdbc.Driver"; int i=0;//测试数据库是否存在该用户 Connection conn =null; PreparedStatement ps=null; ResultSet rs=null; String url="jdbc:mysql://127.0.0.1:3306/Hit_DB"; String user="root"; String password="12345678"; String sql="select user_name,user_password from user_table"; %> <!-- 按六步法完成业务处理 --> <% try{ String user_name1=request.getParameter("username"); String user_password1=request.getParameter("password11"); /* session.setAttribute("uname",user_name1); */ String user_name2=null; String user_password2=null; Class.forName(driver); conn=DriverManager.getConnection(url, user, password); ps=(PreparedStatement)conn.prepareStatement(sql); rs=ps.executeQuery(); while(rs.next()){ user_name2=rs.getString(1); user_password2=rs.getString(2); if(user_name1.equals(user_name2)&&user_password1.equals(user_password2)){ request.getRequestDispatcher("index.html").forward(request,response); i=1; } } if(i==0){ out.println("<script>alert('请重新登录!');window.history.back(-1);</script>"); } i=0; String username = request.getParameter("user_name1"); }catch(SQLException e){ out.print("数据库异常!"); }finally{ } %> <%-- <% String name=request.getParameter("user_name1"); session.setAttribute("uname", name); %> --%> <!-- 关闭对象 --> <% if(rs!=null){ rs.close(); } if(ps!=null){ ps.close(); } if(conn!=null){ conn.close(); } %> </body> </html> person.jsp <%@page import="com.sun.xml.internal.txw2.Document"%> <%@page import="javax.websocket.Session"%> <%@page import="org.apache.catalina.connector.Request"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible" content="ie=edge" /> <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" /> <link rel="stylesheet" type="text/css" href="css/person.css" /> <title>个人页面</title> </head> <body> <%! //定义全局变量 String driver="com.mysql.jdbc.Driver"; String url="jdbc:mysql://127.0.0.1:3306/Hit_DB"; String user="root"; String password="12345678"; /* String username=null; */ String sql="select * from user_table where user_name=?"; Connection conn=null; PreparedStatement ps=null; ResultSet rs=null; %> <% //设置编码,防止乱码现象 request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); %> <% try{ /* String uname=(String)session.getAttribute("uname"); */ String uname = request.getParameter("username"); /* String name=new String(session.getAttribute("name").toString().getBytes("ISO-8859-1"),"UTF-8"); */ Class.forName(driver); conn=DriverManager.getConnection(url,user,password); ps=conn.prepareStatement(sql); ps.setString(1,uname); rs=ps.executeQuery(); /* String users=request.getParameter("username"); */ }catch(SQLException e){ out.print("无法查询!"); } %> <!--导航栏--> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <a href="index.html" class="navbar-brand logo"><img src="images/logo1.png" /></a> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="collapse navbar-collapse" id="navbar-collapse"> <ul class="nav navbar-nav navbar-right"> <li class="nav-li"> <a href="index.html" class="active"><span class="glyphicon glyphicon-home"></span> 首页</a> </li> <li class="nav-li"> <a href="information.html"><span class="glyphicon glyphicon-list"></span> 资讯</a> </li> <li class="nav-li"> <a href="case.html"><span class="glyphicon glyphicon-fire"></span>打卡小明星</a> </li> <li class="nav-li"> <a href="about.html"><span class="glyphicon glyphicon-question-sign"></span> 关于</a> </li> <li> <div class="dropdown hidden-xs"> <img src="images/avatar.jpg" class="dropdown-toggle avatar" data-toggle="dropdown"> <ul class="dropdown-menu"> <li><a href="person.html">个人中心</a></li> <li><a href="CircleOfFriends.html">朋友圈</a></li> <li><a href="massage.html">消息</a></li> <li><a href="published-topics.html">发表</a></li> <li><a href="#">设置</a></li> <li class="divider"></li> <li><a href="xxx">退出</a></li> </ul> </div> </li> </ul> </div> </div> </nav> <!----> <div class="head"> <div class="container"> <div class="row"> <div class="col-md-2 hidden-xs"> <img src="images/avatar.jpg" class="img-circle head-portrait" /> </div> <div class="col-md-10 head-num"> <div class="info"> <strong class="username"> <% sql="select user_nickname,user_sex,user_email from user_table where user_name=?"; conn=null; ps=null; rs=null; %> <% try{ String uname = request.getParameter("username"); conn=DriverManager.getConnection(url,user,password); ps=conn.prepareStatement(sql); ps.setString(1,uname); rs=ps.executeQuery(); while(rs.next()){ String nick=rs.getString("user_nickname"); out.print(nick); } /* String users=request.getParameter("username"); */ }catch(SQLException e){ out.print("无法查询!"); } %> </strong> </div> login.jsp是跳转到index.html这个主界面的,然后从主界面跳转到person.jsp个人界面,个人界面从数据库传数据要用到登陆界面的用户名。。。。
Ajax异步处理跳转不了
这是第一个jsp页面的代码,可以正常进入AjaxServlet ``` var xmlHttpRequest=null; //页面加载 window.onload=function(){ //获取按钮对象 var but=document.getElementById("login"); but.onclick=function(){ //处理ajax //对浏览器判断 if (window.ActiveXOject) { //IE xmlHttpRequest=new ActiveXOject(Microsoft.XMLHTTP); }else{ xmlHttpRequest=new XMLHttpRequest(); } //获取内容 var loginname=document.getElementById("loginname").value; var upassword=document.getElementById("upassword").value; var inputRand=document.getElementById("inputRand").value; //打开链接 xmlHttpRequest.open("get","AjaxServlet?loginname="+loginname+"&upassword="+upassword+"&inputRand="+inputRand+"&type=1"+"&random="+new Date().getTime(),true); //回调函数 xmlHttpRequest.onreadystatechange=AjaxCallBack; //发送 xmlHttpRequest.send(null); } }; //创建回调函数 function AjaxCallBack(){ if (xmlHttpRequest.readyState==4) { if (xmlHttpRequest.status==200) { //读取后台回传的数据 var content=xmlHttpRequest.responseText; var divObject=document.getElementById("resultdiv"); divObject.innerHTML=content; if (content=="登录成功") { window.location.href="index.jsp"; } } } } ``` 这是第二个jsp页面的代码,执行之后没有进入后台AjaxServlet,路径是没有错的 而且不光是进不了AjaxServlet,把URL改成随便的一个JSP页面或者Servlet也跳不过去 ``` var xmlHttpRequest=null; //页面加载 window.onload=function(){ //获取按钮对象 var but=document.getElementById("OK"); but.onclick=function(){ //处理ajax //对浏览器判断 if (window.ActiveXOject) { //IE xmlHttpRequest=new ActiveXOject(Microsoft.XMLHTTP); }else{ xmlHttpRequest=new XMLHttpRequest(); } //获取内容 var oldpassword=document.getElementById("oldpassword").value; var newpassword=document.getElementById("newpassword").value; var renewpassword=document.getElementById("renewpassword").value; //打开链接 //alert("执行到这里"); xmlHttpRequest.open("get","../../AjaxServlet?oldpassword="+oldpassword+"&newpassword="+newpassword+"&renewpassword="+renewpassword+"&type=2",true); //回调函数 xmlHttpRequest.onreadystatechange=AjaxCallBack; //发送 xmlHttpRequest.send(null); } }; //创建回调函数 function AjaxCallBack(){ if (xmlHttpRequest.readyState==4) { if (xmlHttpRequest.status==200) { //读取后台回传的数据 var content=xmlHttpRequest.responseText; var divObject=document.getElementById("resultdiv"); divObject.innerHTML=content; } } } ``` 我是初学者,如果是写法不对,想请教一下怎样在一个项目里面的多个JSP页面实现异步处理
spring mvc+shiro+cas 实现cas client功能 跳转回来404
http://securitycenter.com:8080/gtsys/cas?ticket=ST-14-HEDhc1GVQt0UYdiZpi7R-cas 返回这个地址 404 ![图片说明](https://img-ask.csdn.net/upload/201510/09/1444404164_27274.png) ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd" > <!-- 定时器开关 开始 --> <task:annotation-driven /> <!-- 标注类型 的事务配置 如果使用注解事务。就放开 <tx:annotation-driven />--> <!-- 统一异常处理方式 --> <bean id="exceptionHandler" class="com.lanyuan.exception.MyExceptionHandler"/> <!-- 初始化数据 --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > <property name ="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> <property name="ignoreUnresolvablePlaceholders" value="true" /> </bean> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="driverClassName" value="${jdbc.driverClass}" /> </bean> <bean id="pagePlugin" class="com.lanyuan.plugin.PagePlugin"> <property name="properties"> <props> <prop key="dialect">mysql</prop> <prop key="pageSqlId">.*query.*</prop> </props> </property> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动匹配Mapper映射文件 --> <property name="mapperLocations" value="classpath:mappings/*-mapper.xml"/> <property name="typeAliasesPackage" value="com.lanyuan.entity"/> <property name="plugins"> <array> <ref bean="pagePlugin" /> </array> </property> </bean> <!-- 通过扫描的模式,扫描目录在com.lanyuan.mapper目录下,所有的mapper都继承SqlMapper接口的接口, 这样一个bean就可以了 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.lanyuan.mapper" /> </bean> <!-- 事务配置 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- <aop:config> <aop:pointcut expression="execution(public * com.lanyuan.controller.*(..))" id="pointcut" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="query*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="modify*" propagation="REQUIRED" /> <tx:method name="logicDelById" propagation="REQUIRED" /> </tx:attributes> </tx:advice> --> <!-- <aop:aspectj-autoproxy proxy-target-class="true"/> <bean id="log4jHandlerAOP" class="com.lanyuan.logAop.LogAopAction"></bean> <aop:config proxy-target-class="true"> <aop:aspect id="logAspect" ref="log4jHandlerAOP"> <aop:pointcut id="logPointCut" expression="execution(* org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(..))" /> <aop:around method="logAll" pointcut-ref="logPointCut" /> </aop:aspect> </aop:config> --> <!-- 使用Spring组件扫描的方式来实现自动注入bean --> <context:component-scan base-package="com.lanyuan.task" /> <!-- 隐式地向 Spring 容器注册 --> <context:annotation-config /> </beans> spring-application.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd" > <tx:annotation-driven /> <context:component-scan base-package="com.lanyuan.controller" /> <context:component-scan base-package="com.lanyuan.logAop" /> <!-- 启动对@AspectJ注解的支持 --> <!--通知spring使用cglib而不是jdk的来生成代理方法 AOP可以拦截到Controller--> <aop:aspectj-autoproxy proxy-target-class="true"/> <!-- 注解支持 --> <context:annotation-config/> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJackson2HttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>text/json;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> </bean> <!-- 采用SpringMVC自带的JSON转换工具,支持@ResponseBody注解 --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJackson2HttpMessageConverter" /> <!-- JSON转换器 --> </list> </property> </bean> <!-- 对模型视图名称的解析,即在模型视图名称添加前后缀 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/"></property> <property name="suffix" value=".jsp"></property> </bean> <mvc:annotation-driven> <!-- 处理responseBody 里面日期类型 --> <mvc:message-converters> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="objectMapper"> <bean class="com.fasterxml.jackson.databind.ObjectMapper"> <property name="dateFormat"> <bean class="java.text.SimpleDateFormat"> <constructor-arg type="java.lang.String" value="yyyy-MM-dd HH:mm:ss" /> </bean> </property> </bean> </property> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 默认编码 --> <property name="defaultEncoding" value="utf-8" /> <!-- 文件大小最大值 --> <property name="maxUploadSize" value="10485760000" /> <!-- 内存中的最大值 --> <property name="maxInMemorySize" value="40960" /> </bean> <import resource="spring-mvc-shiro.xml"/> </beans> spring-mvc.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd" > <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" > <property name ="locations"> <list> <value>classpath:jdbc.properties</value> </list> </property> <property name="ignoreUnresolvablePlaceholders" value="true" /> </bean> <bean id="credentialsMatcher" class="com.lanyuan.shiro.credentials.RetryLimitHashedCredentialsMatcher"> <!-- hashAlgorithmName必须的,没有默认值。可以有MD5或者SHA-1,如果对密码安全有更高要求可以用SHA-256或者更高。 这里使用MD5 storedCredentialsHexEncoded默认是true,此时用的是密码加密用的是Hex编码;false时用Base64编码 hashIterations迭代次数,默认值是1。 --> <constructor-arg ref="cacheManager" /> <property name="hashAlgorithmName" value="md5" /> <!--<property name="hashIterations" value="2" />--> <!--<property name="storedCredentialsHexEncoded" value="true" />--> </bean> <!-- 会话Cookie模板 --> <bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie"> <!-- sid如果改为JSESSIONID会导致重定向循环 --> <constructor-arg value="sid"/> <property name="httpOnly" value="true"/> <property name="maxAge" value="-1"/> </bean> <bean id="rememberMeCookie" class="org.apache.shiro.web.servlet.SimpleCookie"> <constructor-arg value="rememberMe"/> <property name="httpOnly" value="true"/> <property name="maxAge" value="2592000"/><!-- 30天 --> </bean> <!-- rememberMe管理器 --> <bean id="rememberMeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager"> <!-- rememberMe cookie加密的密钥 建议每个项目都不一样 默认AES算法 密钥长度(128 256 512 位)--> <property name="cipherKey" value="#{T(org.apache.shiro.codec.Base64).decode('4AvVhmFLUs0KTA3Kprsdag==')}"/> <property name="cookie" ref="rememberMeCookie"/> </bean> <bean id="casSubjectFactory" class="org.apache.shiro.cas.CasSubjectFactory"/> <!-- 凭证匹配器 --> <bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> <property name="realm" ref="casRealm" /> <property name="sessionManager" ref="sessionManager"/> <!-- 使用下面配置的缓存管理器 --> <property name="cacheManager" ref="cacheManager" /> <property name="rememberMeManager" ref="rememberMeManager"/> <property name="subjectFactory" ref="casSubjectFactory"/> </bean> <!-- 相当于调用SecurityUtils.setSecurityManager(securityManager) --> <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="staticMethod" value="org.apache.shiro.SecurityUtils.setSecurityManager"/> <property name="arguments" ref="securityManager"/> </bean> <!--自定义Realm --> <!-- <bean id="myRealm" class="com.lanyuan.shiro.MyRealm"> <property name="credentialsMatcher" ref="credentialsMatcher" /> <property name="cachingEnabled" value="false" /> --> <!-- 如需要自定义缓存时间放开以下.修改 ehcache.xml--> <!--<property name="authenticationCachingEnabled" value="true"/>--> <!--<property name="authenticationCacheName" value="authenticationCache"/>--> <!--<property name="authorizationCachingEnabled" value="true"/>--> <!--<property name="authorizationCacheName" value="authorizationCache"/>--> <!-- </bean> --> <!-- <property name="userService" ref="userService"/> --> <bean id="casRealm" class="com.lanyuan.shiro.MyCasRealm"> <property name="cachingEnabled" value="true"/> <property name="authenticationCachingEnabled" value="true"/> <property name="authenticationCacheName" value="authenticationCache"/> <property name="authorizationCachingEnabled" value="true"/> <property name="authorizationCacheName" value="authorizationCache"/> <!--该地址为cas server地址 --> <property name="casServerUrlPrefix" value="${shiro.casServer.url}"/> <!-- 该地址为是当前应用 CAS 服务 URL,即用于接收并处理登录成功后的 Ticket 的, 必须和loginUrl中的service参数保持一致,否则服务器会判断service不匹配--> <property name="casService" value="${shiro.client.cas}"/> </bean> <bean id="sysUserFilter" class="com.lanyuan.shiro.filter.SysUserFilter"/> <bean id="kickoutSessionControlFilter" class="com.lanyuan.shiro.filter.KickoutSessionControlFilter"> <property name="cacheManager" ref="cacheManager"/> <property name="sessionManager" ref="sessionManager"/> <property name="kickoutAfter" value="false"/> <property name="maxSession" value="1"/> <property name="kickoutUrl" value="/login.shtml"/> </bean> <bean id="casFilter" class="org.apache.shiro.cas.CasFilter"> <!--配置验证错误时的失败页面(Ticket 校验不通过时展示的错误页面) --> <property name="failureUrl" value="${shiro.failureUrl}"/> </bean> <bean id="casLogoutFilter" class="io.github.howiefh.cas.session.CasLogoutFilter"> <property name="sessionManager" ref="sessionManager"/> </bean> <bean id="logoutFilter" class="org.apache.shiro.web.filter.authc.LogoutFilter"> <property name="redirectUrl" value="${shiro.logout.url}"/> </bean> <!-- 配置shiro的过滤器工厂类,id- shiroFilter要和我们在web.xml中配置的过滤器一致 --> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager" /> <!-- <property name="loginUrl" value="/login.shtml" /> <property name="successUrl" value="/index.shtml" /> --> <property name="loginUrl" value="${shiro.login.url}"/> <property name="successUrl" value="${shiro.login.success.url}"/> <property name="unauthorizedUrl" value="/denied.jsp" /> <!-- 自定义权限配置 --> <property name="filterChainDefinitionMap" ref="chainDefinitionSectionMetaSource" /> <property name="filters"> <util:map> <entry key="cas" value-ref="casFilter"/> <entry key="logout" value-ref="logoutFilter" /> <entry key="casLogout" value-ref="casLogoutFilter" /> <entry key="sysUser" value-ref="sysUserFilter"/> <entry key="kickout" value-ref="kickoutSessionControlFilter"/> </util:map> </property> </bean> <!--自定义filterChainDefinitionMap --> <bean id="chainDefinitionSectionMetaSource" class="com.lanyuan.shiro.ChainDefinitionSectionMetaSource"> <property name="filterChainDefinitions"> <value> /casFailure.jsp = anon /cas = casLogout,cas /logout = logout /favicon.ico = anon /admin_files/** = anon /fonts/** = anon /404/** = anon /error.jsp = anon /js/** = anon /layer-v1.9.2/** = anon /notebook/** = anon /login.shtml = anon /denied.jsp = anon /install.shtml = anon /lanyuan.shtml = anon /** = casLogout,user </value> </property> </bean> <bean id="sessionIdGenerator" class="org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator"/> <!-- 会话DAO --> <bean id="sessionDAO" class="org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO"> <property name="activeSessionsCacheName" value="shiro-activeSessionCache"/> <property name="sessionIdGenerator" ref="sessionIdGenerator"/> </bean> <!-- 会话验证调度器 --> <!-- 全局的会话信息检测扫描信息间隔30分钟--> <bean id="sessionValidationScheduler" class="org.apache.shiro.session.mgt.quartz.QuartzSessionValidationScheduler"> <property name="sessionValidationInterval" value="1800000"/> <property name="sessionManager" ref="sessionManager"/> </bean> <!-- 会话管理器 --> <!-- 全局的会话信息设置成30分钟,sessionValidationSchedulerEnabled参数就是是否开启扫描 --> <bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager"> <property name="globalSessionTimeout" value="1800000"/> <property name="deleteInvalidSessions" value="true"/> <property name="sessionValidationSchedulerEnabled" value="true"/> <property name="sessionValidationScheduler" ref="sessionValidationScheduler"/> <property name="sessionDAO" ref="sessionDAO"/> <property name="sessionIdCookieEnabled" value="true"/> <property name="sessionIdCookie" ref="sessionIdCookie"/> </bean> <!--shiro缓存管理器 --> <bean id="cacheManager" class="com.lanyuan.shiro.spring.SpringCacheManagerWrapper" > <property name="cacheManager" ref="springCacheManager"/> </bean> <bean id="springCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"> <property name="cacheManager" ref="ehcacheManager"/> </bean> <!--ehcache--> <bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:ehcache.xml"/> </bean> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor" /> </beans> spring-shiro.xml <web-app xmlns="http://java.sun.com/xml/ns/javaee" 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_3_0.xsd" version="3.0" metadata-complete="false"> <display-name>gtsys</display-name> <!-- 单点登出 --> <!-- <listener> <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> </listener> <filter> <filter-name>CAS Single Sign Out Filter</filter-name> <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class> </filter> <filter-mapping> <filter-name>CAS Single Sign Out Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-shiro.xml,classpath:spring-application.xml</param-value> </context-param> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener> <filter> <filter-name>shiroFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <async-supported>true</async-supported> <init-param> <param-name>targetFilterLifecycle</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>shiroFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>*.shtml</url-pattern> </servlet-mapping> <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> --> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.eot</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.ttf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.css</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.xml</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.swf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.zip</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.gif</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.png</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.woff</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>login.shtml</welcome-file> </welcome-file-list> </web-app> web.xml ## shiro shiro.session.timeout=1800000 shiro.session.validate.timespan=1800000 # cas\u767B\u5F55URL shiro.login.url=https://localhost:8443/cas-server/login?service=http://securitycenter.com:8080/gtsys/cas # cas logout shiro.logout.url=https://localhost:8443/cas-server/logout?service=http://securitycenter.com:8080/gtsys # cas\u767B\u5F55\u6210\u529F\u8DF3\u8F6CURL shiro.login.success.url=http://securitycenter.com:8080/gtsys/index.shtml # cas\u670D\u52A1\u5668URL shiro.casServer.url=https://localhost:8443/cas-server # \u5BA2\u6237\u7AEFCAS\u767B\u5F55URL shiro.client.cas=http://securitycenter.com:8080/gtsys/cas # \u5BA2\u6237\u7AEFCAS\u9A8C\u8BC1\u5931\u8D25\u8DF3\u8F6CURL shiro.failureUrl=/casFailure.jsp ## dataSource dataSource.driver=com.mysql.jdbc.Driver dataSource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8 dataSource.username=root dataSource.password=1234 properties文件 <?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true" monitoring="autodetect" dynamicConfig="true"> <diskStore path="java.io.tmpdir"/> <!-- <diskStore>==========当内存缓存中对象数量超过maxElementsInMemory时,将缓存对象写到磁盘缓存中(需对象实现序列化接口) * <diskStore path="">==用来配置磁盘缓存使用的物理路径,Ehcache磁盘缓存使用的文件后缀名是*.data和*.index * name=================缓存名称,cache的唯一标识(ehcache会把这个cache放到HashMap里) * maxElementsOnDisk====磁盘缓存中最多可以存放的元素数量,0表示无穷大 * maxElementsInMemory==内存缓存中最多可以存放的元素数量,若放入Cache中的元素超过这个数值,则有以下两种情况 * 1)若overflowToDisk=true,则会将Cache中多出的元素放入磁盘文件中 * 2)若overflowToDisk=false,则根据memoryStoreEvictionPolicy策略替换Cache中原有的元素 * eternal==============缓存中对象是否永久有效,即是否永驻内存,true时将忽略timeToIdleSeconds和timeToLiveSeconds * timeToIdleSeconds====缓存数据在失效前的允许闲置时间(单位:秒),仅当eternal=false时使用,默认值是0表示可闲置时间无穷大,此为可选属性 * 即访问这个cache中元素的最大间隔时间,若超过这个时间没有访问此Cache中的某个元素,那么此元素将被从Cache中清除 * timeToLiveSeconds====缓存数据在失效前的允许存活时间(单位:秒),仅当eternal=false时使用,默认值是0表示可存活时间无穷大 * 即Cache中的某元素从创建到清楚的生存时间,也就是说从创建开始计时,当超过这个时间时,此元素将从Cache中清除 * overflowToDisk=======内存不足时,是否启用磁盘缓存(即内存中对象数量达到maxElementsInMemory时,Ehcache会将对象写到磁盘中) * 会根据标签中path值查找对应的属性值,写入磁盘的文件会放在path文件夹下,文件的名称是cache的名称,后缀名是data * diskPersistent=======是否持久化磁盘缓存,当这个属性的值为true时,系统在初始化时会在磁盘中查找文件名为cache名称,后缀名为index的文件 * 这个文件中存放了已经持久化在磁盘中的cache的index,找到后会把cache加载到内存 * 要想把cache真正持久化到磁盘,写程序时注意执行net.sf.ehcache.Cache.put(Element element)后要调用flush()方法 * diskExpiryThreadIntervalSeconds==磁盘缓存的清理线程运行间隔,默认是120秒 * diskSpoolBufferSizeMB============设置DiskStore(磁盘缓存)的缓存区大小,默认是30MB * memoryStoreEvictionPolicy========内存存储与释放策略,即达到maxElementsInMemory限制时,Ehcache会根据指定策略清理内存 * 共有三种策略,分别为LRU(最近最少使用)、LFU(最常用的)、FIFO(先进先出) --> <!-- 注意,以下缓存是永久有效,是系统初始化数据到缓存中,如果不需要永久有效,请另写,或在 --> <cache name="cache" maxEntriesLocalHeap="10000" maxEntriesLocalDisk="1000" eternal="true" diskSpoolBufferSizeMB="20" timeToIdleSeconds="0" timeToLiveSeconds="0" memoryStoreEvictionPolicy="LFU" transactionalMode="off"> </cache> <!-- 登录记录缓存 锁定10分钟 --> <cache name="passwordRetryCache" maxEntriesLocalHeap="2000" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="0" overflowToDisk="false" statistics="true"> </cache> <!-- <cache name="authorizationCache" maxEntriesLocalHeap="2000" eternal="false" timeToIdleSeconds="3600" timeToLiveSeconds="0" overflowToDisk="false" statistics="true"> </cache> <cache name="authenticationCache" maxEntriesLocalHeap="2000" eternal="false" timeToIdleSeconds="3600" timeToLiveSeconds="0" overflowToDisk="false" statistics="true"> </cache> --> <cache name="shiro-activeSessionCache" maxEntriesLocalHeap="2000" eternal="false" timeToIdleSeconds="3600" timeToLiveSeconds="0" overflowToDisk="false" statistics="true"> </cache> <cache name="shiro-kickout-session" maxEntriesLocalHeap="2000" eternal="false" timeToIdleSeconds="3600" timeToLiveSeconds="0" overflowToDisk="false" statistics="true"> </cache> </ehcache> ehcache.xml package com.lanyuan.shiro; //import com.github.zhangkaitao.shiro.chapter15.service.UserService; import java.util.List; import javax.inject.Inject; import org.apache.shiro.SecurityUtils; import org.apache.shiro.authz.AuthorizationInfo; import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.cas.CasRealm; import org.apache.shiro.subject.PrincipalCollection; import com.lanyuan.entity.ResFormMap; import com.lanyuan.mapper.ResourcesMapper; import com.lanyuan.mapper.UserMapper; /** * <p>User: Zhang Kaitao * <p>Date: 14-2-13 * <p>Version: 1.0 */ public class MyCasRealm extends CasRealm { // private UserService userService; // // public void setUserService(UserService userService) { // this.userService = userService; // } @Inject private ResourcesMapper resourcesMapper; @Inject private UserMapper userMapper; @Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { String username = (String)principals.getPrimaryPrincipal(); // PathMatchingFilterChainResolver SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); //authorizationInfo.setRoles(userService.findRoles(username)); // authorizationInfo.setStringPermissions(userService.findPermissions(username)); String userId = SecurityUtils.getSubject().getSession().getAttribute("userSessionId").toString(); List<ResFormMap> rs = resourcesMapper.findUserResourcess(userId); for (ResFormMap resources : rs) { authorizationInfo.addStringPermission(resources.get("resKey").toString()); } return authorizationInfo; } } MyCasRealm.java ``` ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <aop:config proxy-target-class="true"></aop:config> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> </beans> spring-mvc-shiro.xml ``` 这个是更改 网上的蓝缘系统的 cas server 和cas client参考的 http://howiefh.github.io/2015/05/19/shiro-cas-single-sign-on/?utm_source=tuicool 不知道为什么会返回404
<a>标签链接跳转报404错误;但是复制地址在新窗口访问可以正常访问
最近做个web项目,两个系统数据需要打通。webA写了个简单的HTML列表,用<a>标签实现跳转到webB; 核心代码(jQuery): ``` var trHTML = "<tr>" + "<td style='width:60%;'><a href="+url+" >"+theme+"</a></td> "+ "<td style='width:20%;'>"+prename+"</td> "+ "<td style='width:20%;'>"+time+"</td> "+ "</tr>"; jQuery("#eastable").append(trHTML); ``` 但是实际点击<a>标签跳转过去时就报404,必须手工新建一个tab页,复制地址直接访问 第二版: IE可以正常打开,Chrome、Firefox 404报错 ``` var trHTML = "<tr>" + "<td style='width:60%;'><a href='javascript:void(0)' onclick=openEAS('"+ url +"');return false; >"+theme+"</a></td> "+ "<td style='width:20%;'>"+prename+"</td> "+ "<td style='width:20%;'>"+time+"</td> "+ "</tr>"; jQuery("#eastable").append(trHTML); function openEAS(url){ window.open('/EAS/TempLoginEAS.jsp?url='+url,'','scrollbars=yes,fullscreen=yes','') ; } ``` 网上一顿查,无论是绑定onclick方法,用window.open(); 直接打开还是先打开个页面再重定向都是404错误 不知道各位大佬是否遇到过这种问题
SSH框架报错找不到action,求大神指教
我是用 ``` <a class="more" href="/stage/charge/ordershow.action"> ``` 跳转,但是报There is no Action mapped for action name ordershow.错,新手求指教 错误: ``` 六月 06, 2016 11:32:02 上午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn 警告: Could not find action or result There is no Action mapped for action name ordershow. - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189) at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:521) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) ``` strust.xml配置: ``` <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devModel" value="true" /> <include file="json-default.xml" /> <include file="struts-default.xml" /> <package name="login" extends="json-default"> <action name="ordershow" class="orderAction" method="show"> <result name="show">/stage/order/order_info.jsp</result> </action> </package> <constant name="struts.i18n.encoding" value="UTF-8" /> <constant name="struts.locale" value="zh_CN" /> <constant name="struts.ui.theme" value="simple" /> <constant name="struts.ui.templateDir" value="template" /> <constant name="struts.ui.templateSuffix" value="ftl" /> </struts> ``` web.xml: ``` <?xml version="1.0" encoding="UTF-8" ?> <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 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_3_0.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:/spring-*.xml </param-value> </context-param> </web-app> ``` jsp: ``` <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib uri="/struts-tags" prefix="s"%> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> <!DOCTYPE html> <!--[if IE 8]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9]> <html lang="en" class="ie9"> <![endif]--> <!--[if !IE]><!--> <html lang="en"> <!--<![endif]--> <!-- BEGIN HEAD --> <head> <meta charset="utf-8" /> <title>Ttuo-Hotel | 酒店管理系统</title> <meta content="width=device-width, initial-scale=1.0" name="viewport" /> <meta content="" name="description" /> <meta content="" name="author" /> <link href="../assets/bootstrap/css/bootstrap.min.css" rel="stylesheet" /> <link href="../assets/css/metro.css" rel="stylesheet" /> <link href="../assets/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" /> <link href="../assets/font-awesome/css/font-awesome.css" rel="stylesheet" /> <link href="../assets/fullcalendar/fullcalendar/bootstrap-fullcalendar.css" rel="stylesheet" /> <link href="../assets/css/main_style.css" rel="stylesheet" /> <link href="../assets/css/style_responsive.css" rel="stylesheet" /> <link href="../assets/css/style_default.css" rel="stylesheet" id="style_color" /> <link rel="stylesheet" type="text/css" href="../assets/chosen-bootstrap/chosen/chosen.css" /> <link rel="stylesheet" type="text/css" href="../assets/uniform/css/uniform.default.css" /> <link rel="shortcut icon" href="../favicon.ico" /> </head> <!-- END HEAD --> <!-- BEGIN BODY --> <body class="fixed-top"> <!-- BEGIN HEADER --> <div class="header navbar navbar-inverse navbar-fixed-top"> <!-- BEGIN TOP NAVIGATION BAR --> <div class="navbar-inner"> <div class="container-fluid"> <!-- BEGIN LOGO --> <a class="brand" href="index.html"> <img src="../assets/img/logo11.png" alt="logo" /> </a> <!-- END LOGO --> <!-- BEGIN RESPONSIVE MENU TOGGLER --> <a href="javascript:;" class="btn-navbar collapsed" data-toggle="collapse" data-target=".nav-collapse"> <img src="../assets/img/menu-toggler.png" alt="" /> </a> <!-- END RESPONSIVE MENU TOGGLER --> <!-- BEGIN TOP NAVIGATION MENU --> <ul class="nav pull-right"> <!-- BEGIN NOTIFICATION DROPDOWN --> <li class="dropdown" id="header_notification_bar"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-warning-sign"></i> <span class="badge">6</span> </a> <ul class="dropdown-menu extended notification"> <li> <p>You have 14 new notifications</p> </li> <li><a href="javascript:;" onclick=App.onNotificationClick(1);> <span class="label label-success"><i class="icon-plus"></i> </span> New user registered. <span class="time">Just now</span> </a> </li> <li><a href="#"> <span class="label label-important"><i class="icon-bolt"></i> </span> Server #12 overloaded. <span class="time">15 mins</span> </a> </li> <li><a href="#"> <span class="label label-warning"><i class="icon-bell"></i> </span> Server #2 not respoding. <span class="time">22 mins</span> </a> </li> <li><a href="#"> <span class="label label-info"><i class="icon-bullhorn"></i> </span> Application error. <span class="time">40 mins</span> </a> </li> <li><a href="#"> <span class="label label-important"><i class="icon-bolt"></i> </span> Database overloaded 68%. <span class="time">2 hrs</span> </a> </li> <li><a href="#"> <span class="label label-important"><i class="icon-bolt"></i> </span> 2 user IP blocked. <span class="time">5 hrs</span> </a> </li> <li class="external"><a href="#">See all notifications <i class="m-icon-swapright"></i> </a> </li> </ul> </li> <!-- END NOTIFICATION DROPDOWN --> <!-- BEGIN INBOX DROPDOWN --> <li class="dropdown" id="header_inbox_bar"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-envelope-alt"></i> <span class="badge">5</span> </a> <ul class="dropdown-menu extended inbox"> <li> <p>You have 12 new messages</p> </li> <li><a href="#"> <span class="photo"><img src="../assets/img/avatar2.jpg" alt="" /> </span> <span class="subject"> <span class="from">Lisa Wong</span> <span class="time">Just Now</span> </span> <span class="message"> Vivamus sed auctor nibh congue nibh. auctor nibh auctor nibh... </span> </a> </li> <li><a href="#"> <span class="photo"><img src="../assets/img/avatar3.jpg" alt="" /> </span> <span class="subject"> <span class="from">Richard Doe</span> <span class="time">16 mins</span> </span> <span class="message"> Vivamus sed congue nibh auctor nibh congue nibh. auctor nibh auctor nibh... </span> </a> </li> <li><a href="#"> <span class="photo"><img src="../assets/img/avatar1.jpg" alt="" /> </span> <span class="subject"> <span class="from"></span> <span class="time">2 hrs</span> </span> <span class="message"> Vivamus sed nibh auctor nibh congue nibh. auctor nibh auctor nibh... </span> </a> </li> <li class="external"><a href="#">See all messages <i class="m-icon-swapright"></i> </a> </li> </ul> </li> <!-- END INBOX DROPDOWN --> <!-- BEGIN TODO DROPDOWN --> <li class="dropdown" id="header_task_bar"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-tasks"></i> <span class="badge">5</span> </a> <ul class="dropdown-menu extended tasks"> <li> <p>You have 12 pending tasks</p> </li> <li><a href="#"> <span class="task"> <span class="desc">New release v1.2</span> <span class="percent">30%</span> </span> <span class="progress progress-success "> <span style="width: 30%;" class="bar"></span> </span> </a> </li> <li><a href="#"> <span class="task"> <span class="desc">Application deployment</span> <span class="percent">65%</span> </span> <span class="progress progress-danger progress-striped active"> <span style="width: 65%;" class="bar"></span> </span> </a> </li> <li><a href="#"> <span class="task"> <span class="desc">Mobile app release</span> <span class="percent">98%</span> </span> <span class="progress progress-success"> <span style="width: 98%;" class="bar"></span> </span> </a> </li> <li><a href="#"> <span class="task"> <span class="desc">Database migration</span> <span class="percent">10%</span> </span> <span class="progress progress-warning progress-striped"> <span style="width: 10%;" class="bar"></span> </span> </a> </li> <li><a href="#"> <span class="task"> <span class="desc">Web server upgrade</span> <span class="percent">58%</span> </span> <span class="progress progress-info"> <span style="width: 58%;" class="bar"></span> </span> </a> </li> <li><a href="#"> <span class="task"> <span class="desc">Mobile development</span> <span class="percent">85%</span> </span> <span class="progress progress-success"> <span style="width: 85%;" class="bar"></span> </span> </a> </li> <li class="external"><a href="#">See all tasks <i class="m-icon-swapright"></i> </a> </li> </ul> </li> <!-- END TODO DROPDOWN --> <!-- BEGIN USER LOGIN DROPDOWN --> <li class="dropdown user"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> <img alt="" src="../assets/img/avatar1_small.jpg" /> <span class="username"></span> <i class="icon-angle-down"></i> </a> <ul class="dropdown-menu"> <li><a href="extra_profile.html"><i class="icon-user"></i> 我的信息</a> </li> <li><a href="calendar.html"><i class="icon-calendar"></i> 我的日历</a> </li> <li><a href="#"><i class="icon-tasks"></i> 我的任务</a> </li> <li class="divider"></li> <li><a href="hotel.jsp"><i class="icon-key"></i> 退出登录</a> </li> </ul> </li> <!-- END USER LOGIN DROPDOWN --> </ul> <!-- END TOP NAVIGATION MENU --> </div> </div> <!-- END TOP NAVIGATION BAR --> </div> <!-- END HEADER --> <!-- BEGIN CONTAINER --> <div class="page-container row-fluid"> <!-- BEGIN SIDEBAR --> <div class="page-sidebar nav-collapse collapse"> <!-- BEGIN SIDEBAR MENU --> <ul> <li> <!-- BEGIN SIDEBAR TOGGLER BUTTON --> <div class="sidebar-toggler hidden-phone"></div> <!-- BEGIN SIDEBAR TOGGLER BUTTON --> </li> <li> <!-- BEGIN RESPONSIVE QUICK SEARCH FORM --> <form class="sidebar-search"> <div class="input-box"> <a href="javascript:;" class="remove"></a> <input type="text" placeholder="查询. . ." /> <input type="button" class="submit" value=" " /> </div> </form> <!-- END RESPONSIVE QUICK SEARCH FORM --> </li> <li class="has-sub "> <a href="/hotel/index.jsp"> <i class="icon-home"></i> <span class="title">首页</span> <span class="selected"></span> </a> </li> <li class="start active"> <a href="/hotel/stage/stage.jsp"> <i class="icon-bookmark-empty"></i> <span class="title">前台</span> <span class="arrow "></span> </a> <ul class="sub"> <li><a href="/hotel/stage/charge/charge_info.jsp">入住开单</a></li> <li><a href="/hotel/jie">入住详情</a></li> <li><a href="ordershow.action">预定开单</a></li> <li><a href="/hotel/orderfood/food!food.action">订餐服务</a></li> <li><a href="Vip.action">会员管理</a></li> </ul> </li> <li class="has-sub "> <a href="/hotel/restaurant/catering.jsp"> <i class="icon-th-list"></i> <span class="title">餐饮部</span> <span class="arrow "></span> </a> <ul class="sub"> <li><a href="/hotel/restaurant/basic/basic.jsp">餐饮信息</a> </li> <li><a href="/hotel/restaurant/enter/enter!show.action">采购入库</a> </li> <li><a href="/hotel/restaurant/stock/stock.jsp">库存盘点</a> </li> <li><a href="/hotel/restaurant/purchase/purchase!show.action">取材出库</a> </li> </ul> </li> <li class="has-sub "> <a href="/hotel/room/room.jsp"> <i class="icon-star-empty"></i> <span class="title">客房部</span> <span class="arrow "></span> </a> <ul class="sub"> <li><a href="/hotel/room/basic/basic.jsp">基本设置</a> </li> <li><a href="/hotel/room/roommanage/roommanage.jsp">客房管理</a> </li> <li><a href="/hotel/room/damage/damage!show.action">损坏设备统计</a> </li> </ul> </li> <li class="has-sub "> <a href="javascript:;"> <i class="icon-table"></i> <span class="title">统计</span> <span class="arrow "></span> </a> <ul class="sub"> <li ><a href="statistic/room_pie.jsp">房间总体情况</a></li> <li ><a href="statistic/room_stack.jsp">各类型房间情况</a></li> </ul> </li> <li class="has-sub "> <a href="javascript:;"> <i class="icon-briefcase"></i> <span class="title">部门档案</span> <span class="arrow "></span> </a> <ul class="sub"> <li ><a href="department/deptc!show.action">部门分类</a></li> <li ><a href="department/dept!show.action">部门信息</a></li> <li ><a href="department/staff!show.action">人员档案</a></li> </ul> </li> <li class="has-sub "> <a href="javascript:;"> <i class="icon-map-marker"></i> <span class="title">地图</span> <span class="arrow "></span> </a> <ul class="sub"> <li><a></a></li> </ul> </li> <li class="has-sub "> <a href="javascript:;"> <i class="icon-map-marker"></i> <span class="title">公告</span> <span class="arrow "></span> </a> <ul class="sub"> <li><a></a></li> </ul> </li> <li class="has-sub "> <a href="javascript:;"> <i class="icon-briefcase"></i> <span class="title">其他</span> <span class="arrow "></span> </a> <ul class="sub"> <li><a href="profile/profile.jsp">我的信息</a></li> <li><a href="profile/calendar.jsp">我的日程</a></li> <li><a>我的任务</a></li> </ul> </li> <li class=""> <a href="hotel.jsp"> <i class="icon-user"></i> <span class="title">退出登陆</span> </a> </li> </ul> <!-- END SIDEBAR MENU --> </div> <!-- END SIDEBAR --> <div class="page-content"> <!-- BEGIN PAGE CONTAINER--> <div class="container-fluid"> <!-- BEGIN PAGE HEADER--> <div class="row-fluid"> <div class="span12"> <!-- BEGIN STYLE CUSTOMIZER --> <div class="color-panel hidden-phone"> <div class="color-mode-icons icon-color"></div> <div class="color-mode-icons icon-color-close"></div> <br> <div class="color-mode"> <p>主题 颜色</p> <ul class="inline"> <li class="color-black current color-default" data-style="default"></li> <li class="color-blue" data-style="blue"></li> <li class="color-brown" data-style="brown"></li> <li class="color-purple" data-style="purple"></li> <li class="color-white color-light" data-style="light"></li> </ul> <label class="hidden-phone"> <input type="checkbox" class="header" checked value="" /> <span class="color-mode-label">固定标题</span> </label> </div> </div> <!-- END BEGIN STYLE CUSTOMIZER --> <!-- BEGIN PAGE TITLE & BREADCRUMB--> <h3 class="page-title"> 前台<small>请选择内容进行操作:</small> </h3> <ul class="breadcrumb"> <li><i class="icon-home"></i> <a href="/hotel/index.jsp">首页</a> <i class="icon-angle-right"></i> </li> <li><a href="javascript:;">前台</a> </li> </ul> <!-- END PAGE TITLE & BREADCRUMB--> </div> </div> <!-- END PAGE HEADER--> <!-- BEGIN PAGE CONTENT--> <div class="row-fluid"> <div class="span12"> <div id="dashboard"> <!-- BEGIN DASHBOARD STATS --> <div class="row-fluid"> <div class="span2 responsive" data-tablet="span6" data-desktop="span2"> <div class="dashboard-stat yellow"> <div class="visual"> <img src="../assets/img/icon/resize_png_new4.png"> </div> <div class="details"> <div class="number">入住开单</div> <div class="desc"></div> </div> <a class="more" href="/hotel/stage/charge/charge_info.jsp"> 点击浏览更多 <i class="m-icon-swapright m-icon-white"></i> </a> </div> </div> <div class="span2 responsive" data-tablet="span6" data-desktop="span2"> <div class="dashboard-stat green"> <div class="visual"> <img src="../assets/img/icon/33216.png"> </div> <div class="details"> <div class="number">入住详情</div> <div class="desc"></div> </div> <a class="more" href="/hotel/jie"> 点击浏览更多 <i class="m-icon-swapright m-icon-white"></i> </a> </div> </div> <div class="span2 responsive" data-tablet="span6 fix-offset" data-desktop="span2"> <div class="dashboard-stat purple"> <div class="visual"> <img src="../assets/img/icon/resize_png_new7.png"> </div> <div class="details"> <div class="number">预定开单</div> <div class="desc"></div> </div> <a class="more" href="/stage/charge/ordershow.action"> 点击浏览更多 <i class="m-icon-swapright m-icon-white"></i> </a> </div> </div> <div class="span2 responsive" data-tablet="span6 fix-offset" data-desktop="span2"> <div class="dashboard-stat green"> <div class="visual"> <img src="../assets/img/icon/548346.png"> </div> <div class="details"> <div class="number">订餐服务</div> <div class="desc"></div> </div> <a class="more" href="/hotel/orderfood/food!food.action"> 点击浏览更多 <i class="m-icon-swapright m-icon-white"></i> </a> </div> </div> <div class="span2 responsive" data-tablet="span6 fix-offset" data-desktop="span2"> <div class="dashboard-stat yellow"> <div class="visual"> <img src="../assets/img/icon/resize_png_new6.png"> </div> <div class="details"> <div class="number">会员管理</div> <div class="desc"></div> </div> <a class="more" href="Vip.action"> 点击浏览更多 <i class="m-icon-swapright m-icon-white"></i> </a> </div> </div> </div> </div> <!-- END DASHBOARD STATS --> </div> </div> </div> <!-- END PAGE CONTENT--> </div> <!-- END PAGE CONTAINER--> </div> <!-- END PAGE --> <!-- BEGIN FOOTER --> <div class="footer"> 2014 &copy; Ttuo-Hotel | by ToTeam <div class="span pull-right"> <span class="go-top"><i class="icon-angle-up"></i> </span> </div> </div> <!-- END FOOTER --> <!-- BEGIN JAVASCRIPTS --> <!-- Load javascripts at bottom, this will reduce page load time --> <script src="../assets/js/jquery-1.8.3.min.js"></script> <script src="../assets/breakpoints/breakpoints.js"></script> <script src="../assets/jquery-slimscroll/jquery-ui-1.9.2.custom.min.js"></script> <script src="../assets/bootstrap/js/bootstrap.min.js"></script> <script src="../assets/js/jquery.blockui.js"></script> <script src="../assets/js/jquery.cookie.js"></script> <script src="../assets/fullcalendar/fullcalendar/fullcalendar.min.js"></script> <script type="text/javascript" src="../assets/uniform/jquery.uniform.min.js"></script> <script type="text/javascript" src="../assets/chosen-bootstrap/chosen/chosen.jquery.min.js"></script> <!-- ie8 fixes --> <!--[if lt IE 9]> <script src="assets/js/excanvas.js"></script> <script src="assets/js/respond.js"></script> <![endif]--> <script src="../assets/js/app.js"></script> <script> jQuery(document).ready(function() { // initiate layout and plugins App.setPage('calendar'); App.init(); }); </script> <!-- END JAVASCRIPTS --> </body> <!-- END BODY --> </html> ``` ``` ``` java文件: ``` package com.hotel.action.stage; import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; import com.hotel.entity.stage.Orderlist; import com.hotel.entity.stage.RoomAll; import com.hotel.service.stage.OrderService; import com.hotel.utils.Encode; import com.opensymphony.xwork2.ActionSupport; @Controller("orderAction") @Scope("prototype") public class OrderAction extends ActionSupport { @Autowired @Qualifier("orderService") private OrderService os; private Orderlist orderlist = new Orderlist(); private ArrayList<Orderlist> list1 = new ArrayList<Orderlist>(); ArrayList<RoomAll> list2 = new ArrayList<RoomAll>(); private String idds; private int id; private String number; public String save() { orderlist.setName(Encode.toutf8(orderlist.getName())); os.save(orderlist, idds); return "order1"; } public String show() { list1 = os.show(); return "show"; } public String getone() { list2 = os.getone(number); return "get1"; } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public int getId() { return id; } public void setId(int id) { this.id = id; } public Orderlist getOrderlist() { return orderlist; } public ArrayList<Orderlist> getList1() { return list1; } public void setList1(ArrayList<Orderlist> list1) { this.list1 = list1; } public void setOrderlist(Orderlist orderlist) { this.orderlist = orderlist; } public String getIdds() { return idds; } public void setIdds(String idds) { this.idds = idds; } public ArrayList<RoomAll> getList2() { return list2; } public void setList2(ArrayList<RoomAll> list2) { this.list2 = list2; } } ``` 程序结构: ![图片说明](https://img-ask.csdn.net/upload/201606/06/1465185272_322367.png) jsp文件位置: ![图片说明](https://img-ask.csdn.net/upload/201606/06/1465185442_652255.png) jar包: ![图片说明](https://img-ask.csdn.net/upload/201606/06/1465185533_60648.png) ![图片说明](https://img-ask.csdn.net/upload/201606/06/1465185546_855720.png)
JAVA POST登录异常问题?
网上找的HTTP登录代码,登录后返回能200,但是不用用户名密码也返回200,且用Cookie[] cookies = httpClient.getState().getCookies(); StringBuffer tmpcookies = new StringBuffer(); for (Cookie c : cookies) { tmpcookies.append(c.toString() + ";"); System.out.println("cookies = "+c.toString()); } 能取到Cookies,这个搞不懂 登录成功后跳到另一个网页,但是用System.out.println("ResponseBody:\n" + stringBuffer.toString());返回如下: ``` <html> <head><title></title> <SCRIPT LANGUAGE="JavaScript"> var currentWindow = window; if(currentWindow != null){ currentWindow.top.location = "/NMMP/jsp/login.jsp"; } </SCRIPT> </head> ``` 感觉跳转时少了东西,所以跳转后的网页不对,请各们大神帮分析下,或者给个思路,本人不是搞程序的,只是想做一个来应对自己的重复工作,完整代码如下:本人无C币,如果有兴趣帮我做可商量 ``` import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import org.apache.commons.httpclient.Cookie; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; /** * * @ClassName: HttpLogin * @Description: java通过httpclient获取cookie模拟登录 * @author zeze * @date 2015年11月10日 下午4:18:08 * */ public class HttpLogin { public static void main(String[] args) { // 登陆 Url String loginUrl = "http://10.154.13.82:7011/NMMP/jsp/login.jsp"; // 需登陆后访问的 Url String dataUrl = "http://10.154.13.82:7011/NMMP/wyMainAction!init.ilf"; //http://10.154.13.82:7011/NMMP//jsp/wyService/mytasklist.jsp HttpClient httpClient = new HttpClient(); // 模拟登陆,按实际服务器端要求选用 Post 或 Get 请求方式 PostMethod postMethod = new PostMethod(loginUrl); // 设置登陆时要求的信息,用户名和密码 NameValuePair[] data = { new NameValuePair("useraccount", ""), new NameValuePair("password", "Hn_yd45") }; postMethod.setRequestBody(data); try { // 设置 HttpClient 接收 Cookie,用与浏览器一样的策略 httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY); int statusCode=httpClient.executeMethod(postMethod); // 获得登陆后的 Cookie Cookie[] cookies = httpClient.getState().getCookies(); StringBuffer tmpcookies = new StringBuffer(); for (Cookie c : cookies) { tmpcookies.append(c.toString() + ";"); System.out.println("cookies = "+c.toString()); } System.out.println(statusCode); if(statusCode==200){//重定向到新的URL System.out.println("模拟登录成功"); // 进行登陆后的操作 GetMethod getMethod = new GetMethod(dataUrl); // 每次访问需授权的网址时需带上前面的 cookie 作为通行证 // getMethod.setRequestHeader("cookie", tmpcookies.toString()); // 你还可以通过 PostMethod/GetMethod 设置更多的请求后数据 // 例如,referer 从哪里来的,UA 像搜索引擎都会表名自己是谁,无良搜索引擎除外 // postMethod.setRequestHeader("Referer", "http://passport.mop.com/"); getMethod.setRequestHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"); getMethod.setRequestHeader("Referer","http://10.154.13.82:7011/NMMP/login.ilf"); getMethod.setRequestHeader("Accept-Encoding","gzip, deflate"); getMethod.setRequestHeader("Accept-Language","zh-CN,zh;q=0.9"); getMethod.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" ); httpClient.executeMethod(getMethod); statusCode=httpClient.executeMethod(getMethod); System.out.println("模拟登录成功"+statusCode); // 打印出返回数据,检验一下是否成功 // String text = getMethod.getResponseBodyAsString(); InputStream inputStream = getMethod.getResponseBodyAsStream(); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); StringBuffer stringBuffer = new StringBuffer(); String str= ""; while((str = br.readLine()) != null){ stringBuffer .append(str ); } System.out.println("ResponseBody:\n" + stringBuffer.toString()); HttpRequestProxy hrp = new HttpRequestProxy(); Map date = new HashMap(); date.put("jyidApplet", "1"); date.put("codeNumApplet", "1"); date.put("jymxIdApplet", "447"); date.put("patientIdApplet", "1118"); String str1 = hrp.doRequest(dataUrl,date, null, null); System.out.println("sd"+str1); } else { System.out.println("登录失败"); } } catch (Exception e) { e.printStackTrace(); } } } ``` 登录网页源码如下: ``` <html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>综合管理系统</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <style type="text/css"> *{ margin:auto; } html,body{ overflow:hidden; width:100%; height:100%; margin:auto; } body{ background:url(/NMMP/common-skins/maintain/images/login_bg_1.0.gif); } #login_panel{ background-image:url(/NMMP/common-skins/maintain/images/login_panel_bg_1.0.png); background-repeat:repeat-x; height:640px; width:100%; text-align:center; position:relative; } #login_input{ background-image:url(/NMMP/common-skins/maintain/images/login_input_1.0.png); background-repeat:no-repeat; width:668px; height:403px; position:relative; } #useraccount{ border:none; position:absolute; left:392px; top:149px; height:24px; width:136px; background-color:#99deff; } #password{ border:none; position:absolute; left:392px; top:183px; height:24px; width:136px; background-color:#99deff; } #login_botton{ position:absolute; left:537px; _left:538px; top:147px; } #message{ position:absolute; left:348px; top:218px; color:#F00; font-size:14px; font-weight:bold; } #technical{ position:absolute; left:375px; top:258px; text-align:left; color:#CCC; font-size:12px; line-height:30px; } #copyright{ position:absolute; bottom:65px; right:0px; color:#CCC; font-size:12px; text-align:right; line-height:20px; } </style> <!--[if IE 6]> <script language="javascript" type="text/javascript" src="/NMMP/common-skins/default/jslib/DD_belatedPNG.js"> </script> <script language="javascript" type="text/javascript"> DD_belatedPNG.fix('#login_panel'); DD_belatedPNG.fix('#login_input'); </script> <![endif]--> </head> <body windowc_onresizez="true"> <div id="login_panel"> <div id="login_input" style="top: 110.5px;"> <form name="form1" action="/NMMP/CtrlUser.action?action=login&amp;surl=jsp/home/main.jsp&amp;furl=jsp/login.jsp" method="post" 360chrome_form_autofill="2"> <input name="useraccount" id="useraccount" style="background-color: rgb(250, 255, 189);" required="true" type="text"> <input name="password" id="password" style="background-color: rgb(250, 255, 189);" required="true" type="password"> <input id="login_botton" type="image" src="/NMMP/common-skins/maintain/images/login_botton.png"> <div id="message"> </div> <!-- div id="technical"><a style="color:orange" href="javascript:void(0)" onclick="resetpwd();">密码重置</a></div--> <div id="copyright">版权所有:</div> </form> </div> </div> <script language="javascript" type="text/javascript"> document.getElementById("login_input").style.top=(document.body.clientHeight-403)/2+"px"; function resetpwd(){ var url = "/NMMP/resetpwdAction.ilf"; window.location.href=url; } </script> </body></html> ```
JSp+ajax用户登录验证
[img]http://dl2.iteye.com/upload/attachment/0088/2001/4ee085e5-47e0-3995-ad42-62e4a53cfc2f.png[/img] 用户登陆界面,想要实现输入账号之后离开输入框就验证该账号是否存在,输入角色、账号、密码之后,点击登录,如果正确就跳转到index.jsp,错误不跳转并且在密码输入框下显示提示信息;有一个没输入就提示,信息也是在密码输入框下。 我现在的问题是:若果什么也不输,点击登录,会闪一下,但闪过之后就是重置了页面。输入正确也是闪一下就重置页面.账号验证没问题,就是登录有问题,但是搞不定,大侠们看看吧! login.jsp [code="java"]<form id="form" name="form" method="post" action="" > <table border="0"> <tr> <td align="right">角色类型:</td> <td><select name="role" id="role" onBlur="checkRole(this)"> <option value="0">-请选择角色-</option> <% List<Role> list = new ArrayList<Role>(); RoleDao dao = new RoleDaoImpl(); list = dao.findAllRoles();//调用实现类的查询全部方法 for (int i = 0; i < list.size(); i++) { Role r = list.get(i); %> <option value="<%=r.getR_id()%>"><%=r.getR_name()%></option> <% } %> </select> </td> <td align="left"> &nbsp; <span id="roleSpan"></span> </td> </tr> <tr> <td align="right">账号:</td> <td> <input type="text" name="number" id="number" onblur="checkNumber(this)"> </td> <td width="256" align="left"> &nbsp; <span id="numberSpan"></span> </td> </tr><!-- 当输入名字后离开输入框即调用--> <tr> <td align="right">密码:</td> <td><input type="password" name="pwd" id="pwd" onBlur="checkPsw(this)" > </td> <td align="left"> &nbsp; <span id="pwdSpan"></span> </td> </tr> <tr> <td align="left">&nbsp;<span id="feedback_info"></span></td> </tr> <tr> <td colspan="1"> <input type="submit" value="登录" onclick="checkLogin(this.form)"/> <input type="button" value="注册" onclick="javascript:window.location.href='User/Register.jsp'"></td> </tr> </table> </form>[/code] login.js [code="java"]var xmlHttp; function createXMLHttpRequest() { if (window.XMLHttpRequest) { var xmlHttp = new XMLHttpRequest(); //mozilla浏览器 } else if (window.ActiveXObject) { try { var xmlHttp = new ActiveX0bject("Msxml2.XMLHTTP"); //IE老版本 } catch (e) { } try { var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE新版本 } catch (e) { } } if (!xmlHttp) { window.alert("不能创建XMLHttpRequest对象实例"); return false; } else return xmlHttp; ////}///////花括号放错地方 } // 检查账号,给出提示信息 function checkNumber(Number) { var numberSpan = document.getElementById("numberSpan"); if (Number.value == "") { numberSpan.innerHTML = "账号必须填写".fontcolor("red"); return false; } else { xmlHttp = createXMLHttpRequest(); //createXMLHttpRequest申明的是局部变量,这里访问不到xmlHttp,要给xmlHttp变量赋值才行 var url="servlet/CheckNumberServlet?number="+Number.value+"&LoginTime="+new Date().getTime(); url = encodeURI(url); //转换码后再传输 xmlHttp.open("GET",url,true);//加时间戳防止IE缓存 //xmlhttp.setRequestHeader( "Content-Type", "text/html;charset=UTF-8" ); xmlHttp.onreadystatechange = handleStateChange1; xmlHttp.send(null); return true; } } function handleStateChange1() { var numberSpan = document.getElementById("numberSpan"); if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { // alert("来自服务器的响应:"+xmlHttp.responseText); if (xmlHttp.responseText == 'true') {///////responseText是字符串,不能和boolean变量直接比较 // alert("存在"); numberSpan.innerHTML = "<img src='Img/g.gif'>"; document.getElementById("feedback_info").innerHTML=""; return true; } else if (xmlHttp.responseText == 'false') {///////responseText是字符串,不能和boolean变量直接比较 // alert("不存在"); numberSpan.innerHTML = "账号不存在".fontcolor("red"); return false; } } else alert("服务器端错误"); } } // 检查密码,给出提示信息 function checkPsw(pswNode) { var spanNode1 = document.getElementById("pswSpan"); var Role= document.getElementById("role"); var Number= document.getElementById("number"); if (pswNode.value == "") { spanNode1.innerHTML = "密码必须填写".fontcolor("red"); return false; } else { pwdSpan.innerHTML = "<img src='Img/g.gif'>"; document.getElementById("feedback_info").innerHTML=""; return true; } } // 检查是否选中角色 function checkRole(selNode) { var index = selNode.selectedIndex;// 获得选中下标 var spanNode1 = document.getElementById("roleSpan"); if (index <= 0) { spanNode1.innerHTML = "必须选择角色".fontcolor("red"); return false; } else { spanNode1.innerHTML = "<img src='Img/g.gif'>"; document.getElementById("feedback_info").innerHTML=""; return true; } } // 检查表单 function checkLogin(o) { var Role=o.role; var Number= o.number; var Pwd= o.pwd; if(checkNumber(Number)&&checkPsw(Psw) &&checkRole(Role)) { xmlHttp = createXMLHttpRequest(); //createXMLHttpRequest申明的是局部变量,这里访问不到xmlHttp,要给xmlHttp变量赋值才行 var url="servlet/CheckLoginServlet?number="+Number.value+"&role="+Role.value+"&pwd="+Pwd.value+"&LoginTime="+new Date().getTime(); url = encodeURI(url); //转换码后再传输 xmlHttp.open("GET",url,true);//加时间戳防止IE缓存 //xmlhttp.setRequestHeader( "Content-Type", "text/html;charset=UTF-8" ); xmlHttp.onreadystatechange = handleStateChange2; xmlHttp.send(null); return true; } else{ document.getElementById("feedback_info").innerHTML="请填写每一项".fontcolor("red"); return false; } } function handleStateChange2() { if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { //alert("来自服务器的响应:" + xmlHttp.responseText); if(xmlHttp.responseText == '0'){ document.getElementById("feedback_info").innerHTML="账号与密码不匹配".fontcolor("red"); return false; } else if(xmlHttp.responseText == '1'){ document.getElementById("feedback_info").innerHTML=""; window.location.href="index.jsp"; return true; } } else alert("服务器端错误"); } }[/code] chuckLoginservlet [code="java"]public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); doPost(request, response);// 调用doPost方法 } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=UTF-8"); String number=""; try { number = new String(request.getParameter("number").getBytes( "ISO-8859-1"), "UTF-8"); } catch (Exception e1) { System.out.println("number为空"); } String role="0"; int rID=0; try { role = new String(request.getParameter("role").getBytes( "ISO-8859-1"), "UTF-8"); rID=Integer.parseInt(role);//把获得的role的值转成整型 } catch (Exception e1) { System.out.println(request.getParameter("role")+"******role"); } String pwd=""; try { pwd = new String(request.getParameter("pwd").getBytes( "ISO-8859-1"), "UTF-8"); } catch (Exception e) { System.out.println(request.getParameter("pwd")+"****pwd"); } // String txt = new String(number.getBytes("ISO-8859-1"), "UTF-8"); // System.out.println(txt+"********"); PrintWriter out = response.getWriter(); User u = new User(); UserDao ud = new UserDaoImpl(); u = ud.findUserByNumber(number);//通过账号找到用户对象 if (u != null) {// 找到该用户 int u_id = u.getU_id();// 获得该用户的ID UserRole ur = new UserRole(); UserRoleDao urd = new UserRoleDaoImpl(); ur = urd.findUserRoleByUserId(u_id);// 找到中间表UserRole的记录 int r_id = ur.getRole().getR_id();// 由Userrole表找到Role表的相对应角色名称 if (r_id==rID && u.getU_password().equals(pwd))// 如果数据中的角色和密码与之对应 { out.write("1");//1表示验证通过 } else { out.write("0");//0表示密码与账号不匹配 } } out.flush(); out.close(); }[/code]
ssm 报错:org.springframework.context.annotation.internalAsyncAnnotationProcessor
# ssm 框架 在本地完美运行放到Linux服务器报错 以下内容 Error creating bean with name '**org.springframework.context.annotation.internalAsyncAnnotationProcessor'**: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.interceptor.AsyncExecutionInterceptor.<init>(Ljava/util/concurrent/Executor;Lorg/springframework/aop/interceptor/AsyncUncaughtExceptionHandler;)V ## 之前是没有加 redis,没有发现问题,这次我加了redis然后就报错,大神们帮忙看看解决解决 这是spring-mvc配置: ``` ==============spring-mvc===================== <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd" > <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <mvc:annotation-driven/> <context:component-scan base-package="com.bls.mp.*"/> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <bean class="com.bls.mp.common.SpringTool"/> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> <!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> JSON转换器 </list> </property> </bean>--> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> <property name="prefix" value="/WEB-INF/resources/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 默认编码 --> <property name="defaultEncoding" value="utf-8" /> <!-- 文件大小最大值 --> <property name="maxUploadSize" value="10485760000" /> <!-- 内存中的最大值 --> <property name="maxInMemorySize" value="40960" /> </bean> <!-- 全局异常处理器 --> <bean class="com.bls.mp.common.exception.CustomExceptionResolver"></bean> <mvc:annotation-driven/> <!-- 拦截器配置 --> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/setadmin"/> <!--<mvc:mapping path="/user/userList"/> --> <mvc:mapping path="/Blocker"/> <mvc:mapping path="/grouponteam/grouponRanking"/> <mvc:mapping path="/grouponteam/arriverTime"/> <mvc:mapping path="/grouponteam/paging"/> <mvc:mapping path="/grouponteam/conditionGrouponT"/> <mvc:mapping path="/hospital/hospitalInfo"/> <mvc:mapping path="/hospital/setting"/> <mvc:mapping path="/hospital/orderdetails"/> <mvc:mapping path="/grouponteam/grouponTeamCountAndMoney"/> <mvc:mapping path="/grouponteam/OrderRefundList"/> <mvc:mapping path="/grouponteam/orderdetails"/> <mvc:mapping path="/grouponteam/paging"/> <mvc:mapping path="/grouponteam/conditionGrouponT"/> <mvc:mapping path="/grouponteam/grouponRanking"/> <mvc:mapping path="/grouponteam/arriverTime"/> <mvc:mapping path="/grouponteam/grouponTeamCountAndMoney"/> <mvc:mapping path="/imguoload"/> <mvc:mapping path="/imguoloads"/> <mvc:mapping path="/uploadFile"/> <mvc:mapping path="/uploadCenter"/> <mvc:mapping path="/onTheShelves"/> <mvc:mapping path="/updateTheRecommended"/> <mvc:mapping path="/deleteByGoods"/> <mvc:mapping path="/restoreGoods"/> <mvc:mapping path="/goods/goodslist"/> <mvc:mapping path="/goods/hasBeenOn"/> <mvc:mapping path="/goods/NotOn"/> <mvc:mapping path="/goods/RecycleBin"/> <mvc:mapping path="/goods/searchName"/> <mvc:mapping path="/goods/goodsdiy"/> <mvc:mapping path="/upload/uploadFile"/> <mvc:mapping path="/CreateClassImg"/> <mvc:mapping path="/imglist"/> <mvc:mapping path="/up_img"/> <mvc:mapping path="/moveImg"/> <mvc:mapping path="/deleteImg"/> <mvc:mapping path="/template/templateURL"/> <mvc:mapping path="/template/templateParentAll"/> <mvc:mapping path="/template/templatAll"/> <mvc:mapping path="/template/changeT"/> <mvc:mapping path="/template/deleteT"/> <mvc:mapping path="/TemplateMsg/addTemplateMsg"/> <mvc:mapping path="/TemplateMsg/templateMsgList"/> <mvc:mapping path="/TemplateMsg/templateSendlist"/> <mvc:mapping path="/TemplateMsg/TemplateSendMsg"/> <mvc:mapping path="/TemplateMsg/updataPTID"/> <mvc:mapping path="/TemplateMsg/deleteMB"/> <mvc:mapping path="/ThirdData/getdata"/> <mvc:mapping path="/ThirdData/updata"/> <mvc:mapping path="/setMoney/setMoneyList"/> <mvc:mapping path="/setMoney/setArriveMoney"/> <mvc:mapping path="/setMoney/checkfileCert"/> <mvc:mapping path="/setMoney/SetMoneyType"/> <mvc:mapping path="/user/userlists"/> <mvc:mapping path="/user/uOpenId"/> <mvc:mapping path="/visitor/theAlmostMoon"/> <mvc:mapping path="/visitor/SixAlmostMoon"/> <mvc:mapping path="/visitor/tops"/> <mvc:mapping path="/weixin/REFUND"/> <bean class="com.bls.mp.interceptor.AuthInterceptor"></bean> </mvc:interceptor> </mvc:interceptors> <task:annotation-driven/> <!-- 配置访问静态文件 --> <mvc:default-servlet-handler/> <mvc:resources location="/images/" mapping="/images/**"/> <mvc:resources location="/WEB-INF/js/" mapping="/js/**"/> <mvc:resources location="/WEB-INF/resources/jsp/" mapping="/jsp/**"/> <mvc:resources location="/WEB-INF/resources/css/" mapping="/css/**"/> </beans> ``` 这是 web.xml ``` ==============web.xml===================== <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mybatis.xml</param-value> <param-value>classpath:spring-redis.xml</param-value> </context-param> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>CORSFilter</filter-name> <filter-class>com.bls.mp.common.MyFilter</filter-class> <init-param> <param-name>excludedPages</param-name> <param-value>/UserAuthServlet</param-value> </init-param> </filter> <filter-mapping> <filter-name>CORSFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> </web-app> ``` 这是spring-mybatis.xml 配置 ``` ==============spring-mybatis.xml===================== <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 自动扫描 --> <context:component-scan base-package="com.bls.mp"/> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/bls/mp/mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.bls.mp.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> </beans> ``` 这是spring-redis.xml配置 ``` ===================spring-redis.xml============== <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:property-placeholder location="classpath:*.properties"/> <!--设置数据池--> <bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxIdle" value="${redis.maxIdle}"></property> <property name="minIdle" value="${redis.minIdle}"></property> <property name="maxTotal" value="${redis.maxTotal}"></property> <property name="maxWaitMillis" value="${redis.maxWaitMillis}"></property> <property name="testOnBorrow" value="${redis.testOnBorrow}"></property> </bean> <!--链接redis--> <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="hostName" value="${redis.host}"></property> <property name="port" value="${redis.port}"></property> <property name="password" value="${redis.password}"></property> <property name="timeout" value="${redis.timeout}"></property> <property name="poolConfig" ref="poolConfig"></property> </bean> <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" p:connection-factory-ref="connectionFactory" > <!--以下针对各种数据进行序列化方式的选择--> <property name="keySerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> <property name="valueSerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> <property name="hashKeySerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property> <!--<property name="hashValueSerializer"> <bean class="org.springframework.data.redis.serializer.StringRedisSerializer" /> </property>--> </bean> </beans> ```
Java ssm 框架 访问报错500
报错如下: ``` HTTP Status 500 – Internal Server Error Type Exception Report Message Servlet.init() for servlet SpringMVC threw exception Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception javax.servlet.ServletException: Servlet.init() for servlet SpringMVC threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745) Root Cause org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotation.internalAsyncAnnotationProcessor': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.interceptor.AsyncExecutionInterceptor.<init>(Ljava/util/concurrent/Executor;Lorg/springframework/aop/interceptor/AsyncUncaughtExceptionHandler;)V org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:220) org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745) Root Cause java.lang.NoSuchMethodError: org.springframework.aop.interceptor.AsyncExecutionInterceptor.<init>(Ljava/util/concurrent/Executor;Lorg/springframework/aop/interceptor/AsyncUncaughtExceptionHandler;)V org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor.<init>(AnnotationAsyncExecutionInterceptor.java:60) org.springframework.scheduling.annotation.AsyncAnnotationAdvisor.buildAdvice(AsyncAnnotationAdvisor.java:150) org.springframework.scheduling.annotation.AsyncAnnotationAdvisor.<init>(AsyncAnnotationAdvisor.java:99) org.springframework.scheduling.annotation.AsyncAnnotationBeanPostProcessor.setBeanFactory(AsyncAnnotationBeanPostProcessor.java:105) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1585) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:220) org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:615) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:465) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:341) org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1441) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:745) Note The full stack trace of the root cause is available in the server logs. Apache Tomcat/8.5.12 ``` 一搭到服务器上就出现这个错误,但是本地window没问题;卡了一天了,脑瓜子呼呼的,第一次用这个玩意,实在看不出来啥问题了,有没有大佬帮忙指点指点,给条明路呀!! 下面是几个基础配置: web.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mybatis.xml</param-value> </context-param> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>CORSFilter</filter-name> <filter-class>com.bls.mp.common.MyFilter</filter-class> <init-param> <param-name>excludedPages</param-name> <param-value>/UserAuthServlet</param-value> </init-param> </filter> <filter-mapping> <filter-name>CORSFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> </web-app> ``` spring-mvc.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd" > <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <context:component-scan base-package="com.bls.mp.controller"/> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- <bean id="thirdDataService" class="com.bls.mp.service.impl.ThirdDataServiceImpl"/>--> <bean class="com.bls.mp.common.SpringTool"/> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> <!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> JSON转换器 </list> </property> </bean>--> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> <property name="prefix" value="/WEB-INF/resources/jsp/" /> <property name="suffix" value=".jsp" /> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property> </bean> <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 默认编码 --> <property name="defaultEncoding" value="utf-8" /> <!-- 文件大小最大值 --> <property name="maxUploadSize" value="10485760000" /> <!-- 内存中的最大值 --> <property name="maxInMemorySize" value="40960" /> </bean> <!-- 全局异常处理器 --> <bean class="com.bls.mp.common.exception.CustomExceptionResolver"></bean> <mvc:annotation-driven/> <!-- 拦截器配置 --> <mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/setadmin"/> <!--<mvc:mapping path="/user/userList"/> --> <mvc:mapping path="/Blocker"/> <mvc:mapping path="/goods/goods"/> <bean class="com.bls.mp.interceptor.AuthInterceptor"></bean> </mvc:interceptor> </mvc:interceptors> <task:annotation-driven/> <!-- 配置访问静态文件 --> <mvc:default-servlet-handler/> <mvc:resources location="/images/" mapping="/images/**"/> <mvc:resources location="/WEB-INF/js/" mapping="/js/**"/> <mvc:resources location="/WEB-INF/resources/jsp/" mapping="/jsp/**"/> <mvc:resources location="/WEB-INF/resources/css/" mapping="/css/**"/> </beans> ``` spring-mybatis.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 自动扫描 --> <context:component-scan base-package="com.bls.mp"/> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:jdbc.properties" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/bls/mp/mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.bls.mp.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> </beans> ``` jdk版本: 1.8.0_222 tomcat 版本:8.0 有没有大佬来给看看呀0.0
权限问题!
public class userfiter implements Filter{ String noFilterURL=""; public void destroy() { } public void init(FilterConfig arg0) throws ServletException { noFilterURL=arg0.getInitParameter("noFilter"); } public void doFilter(ServletRequest req, ServletResponse res, FilterChain chai) throws IOException, ServletException { HttpServletRequest request=(HttpServletRequest)req; String tmpstr=request.getRequestURI().substring(request.getRequestURI().indexOf("/")+1); String uri=tmpstr.substring(tmpstr.indexOf("/")); if(noFilterURL.indexOf(uri)<0) { HttpSession session=null; session=request.getSession(); if((session.getAttribute("login"))==null) { request.setAttribute("error","请先登录"); RequestDispatcher dis=req.getRequestDispatcher("/login.jsp"); dis.forward(req, res); return; } } chai.doFilter( req, res); } } <filter> <filter-name>UserFilter</filter-name> <filter-class>com.web.userfiter</filter-class> <init-param> <param-name>noFilter</param-name> <param-value>/login.jsp,/login.do,/images/login_background.gif, /images/login.jpg,/images/login.bmp-</paramvalue> </init-param> </filter> <filter-mapping> <filter-name>UserFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 这是我写的过滤器,和web.xml的配置文件。但是这没达到我想要的效果,例如我在IE里面http://localhost:8089/OA/login.do,可以提交,但如果把login.do也过滤掉,那就不能登录了!但又不想让直接在IE里面输入http://localhost:8089/OA/login.do提交!还有如果是http://localhost:8089/OA/massge/index.jsp,它是不能登录,可以跳转到http://localhost:8089/OA/login.jsp,但是图片又不显示出来,如果.do提交,返回到http://localhost:8089/OA/login.jsp页面,图片又可能显示出来! 我想的效果是无论从什么方式提交,只要没登录,都要返回到login.jsp页面!当然图片也要显示出来!就是权限问题,没登录,无论你什么方式提交也不能访问其它页面,在怎么做呢?如果用Action做,那.jsp页面就不能过滤掉了,能访问到静态的页面! 要怎么做呢?请帮忙看看!谢谢!给我点意见咯!谢谢...感激不尽!
今天小妹搭一个ssm框架,但是就是报404,大神能帮忙看一下吗
1.先贴上代码结构 ![图片说明](https://img-ask.csdn.net/upload/201802/23/1519372058_795994.png) 2.配置如下 web.xml ![图片说明](https://img-ask.csdn.net/upload/201802/23/1519372803_835812.png)![图片说明](https://img-ask.csdn.net/upload/201802/23/1519372813_171670.png)![图片说明](https://img-ask.csdn.net/upload/201802/23/1519372821_410087.png) spring-mvc.xml 如下: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <context:component-scan base-package="com.part3.controller" /> <!--避免IE执行AJAX时,返回JSON出现下载文件 --> <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> </list> </property> </bean> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 --> </list> </property> </bean> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <!-- 配置文件上传,如果没有使用文件上传可以不用配置,当然如果不配,那么配置文件中也不必引入上传组件包 --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <!-- 默认编码 --> <property name="defaultEncoding" value="utf-8" /> <!-- 文件大小最大值 --> <property name="maxUploadSize" value="10485760000" /> <!-- 内存中的最大值 --> <property name="maxInMemorySize" value="40960" /> </bean> </beans> ``` spring-mybatis.xml 如下 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <context:annotation-config /> <!-- 自动扫描 --> <context:component-scan base-package="com.part3.controller"/> <context:component-scan base-package="com.part3.service"/> <context:component-scan base-package="com.part3.dao" /> <!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <!-- <property name="location" value="classpath:jdbc.properties" /> --> <property name="locations"> <list> <value>classpath:log4j.properties</value> <value>classpath:jdbc.properties</value> </list> </property> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${driver}" /> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> <!-- 初始化连接大小 --> <property name="initialSize" value="${initialSize}"></property> <!-- 连接池最大数量 --> <property name="maxActive" value="${maxActive}"></property> <!-- 连接池最大空闲 --> <property name="maxIdle" value="${maxIdle}"></property> <!-- 连接池最小空闲 --> <property name="minIdle" value="${minIdle}"></property> <!-- 获取连接最大等待时间 --> <property name="maxWait" value="${maxWait}"></property> </bean> <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:sqlMapConfig.xml" /> <property name="typeAliasesPackage" value="com.part3.pojo" /> <!-- mapper配置路径 --> <!-- 自动扫描mapper.xml文件 --> <!-- mapper配置路径 --> <property name="mapperLocations"> <list> <!-- 表示在com.ws.map包或以下所有目录中,以-mapper.xml结尾所有文件 --> <value>classpath:com/part3/mapping/*.xml</value> </list> </property> </bean> <!-- 扫描Mapper中的抽象类 ,实例化之后会自动装配--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.part3.mapping" /> <property name="markerInterface" value="com.part3.mapping.SqlMapper" /> </bean> <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> </beans> ``` sqlMapConfig.xml 如下 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 配置设置 --> <settings> <!-- 配置全局性 cache 的 ( 开 / 关) default:true --> <setting name="cacheEnabled" value="true"/> <!-- 是否使用 懒加载 关联对象 同 hibernate中的延迟加载 一样 default:true --> <setting name="lazyLoadingEnabled" value="true"/> <!-- [当对象使用延迟加载时 属性的加载取决于能被引用到的那些延迟属性,否则,按需加载(需要的是时候才去加载)] --> <setting name="aggressiveLazyLoading" value="true"/> <!-- 是否允许单条sql 返回多个数据集 (取决于驱动的兼容性) default:true --> <setting name="multipleResultSetsEnabled" value="true"/> <!-- 是否可以使用列的别名 (取决于驱动的兼容性) default:true--> <setting name="useColumnLabel" value="true"/> <!--允许JDBC 生成主键。需要驱动器支持。如果设为了true,这个设置将强制使用被生成的主键,有一些驱动器不兼容不过仍然可以执行。 default:false--> <setting name="useGeneratedKeys" value="false"/> <!--指定 MyBatis 如何自动映射 数据基表的列 NONE:不隐射 PARTIAL:部分 FULL:全部--> <setting name="autoMappingBehavior" value="PARTIAL"/> <!-- 这是默认的执行类型 SIMPLE :简单 REUSE:执行器可能重复使用prepared statements 语句 BATCH:执行器可以重复执行语句和批量更新 --> <setting name="defaultExecutorType" value="SIMPLE"/> <!-- 设置驱动等待数据响应的超时数 默认没有设置--> <setting name="defaultStatementTimeout" value="25000"/> <!-- [是否启用 行内嵌套语句 defaut:false] --> <setting name="safeRowBoundsEnabled" value="false"/> <!-- [是否 启用 数据中 A_column 自动映射 到 java类中驼峰命名的属性 default:fasle] --> <setting name="mapUnderscoreToCamelCase" value="false"/> <!-- 设置本地缓存范围 session:就会有数据的共享 statement:语句范围 (这样就不会有数据的共享 ) defalut:session --> <setting name="localCacheScope" value="SESSION"/> <!-- 设置但JDBC类型为空时,某些驱动程序 要指定值,default:other --> <setting name="jdbcTypeForNull" value="OTHER"/> <!-- 设置触发延迟加载的方法 --> <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/> </settings> <!-- 别名 <typeAliases> <typeAlias type="com.ws.poi.user.User" alias="User" /> </typeAliases> --> </configuration> ``` ``` 运行后,控制台如下![图片说明](https://img-ask.csdn.net/upload/201802/23/1519372724_823687.png) 页面如下,直接执行报错404![图片说明](https://img-ask.csdn.net/upload/201802/23/1519372736_100549.png) 就是找不出什么问题,小妹实在无奈了,有大神帮忙看看吗?自学很累
问一个关于一个session的问题在struts2 中
先看看看我的一段代码, [code="java"]public String toLogin() throws Exception { try { Map<String, Register> session=ActionContext.getContext().getSession(); register = authorService.loginValid(userName, passWord); if(register !=null){ session.put("register",register); id = register.getId(); return SUCCESS; }else{ addActionError("用户名/密码不匹配"); this.setTip("<font color='red'>对不起您的帐号或密码有误!</font>"); return "failure"; } } catch (Exception e) { // TODO: handle exception this.setTip("<font color='red'>对不起,系统出现故障,请稍后再登录!</font>"); e.printStackTrace(); return "failure"; } } [/code] [code="java"]<action name="login" class="loginAction" method="toLogin"> <result name="input">/login/authorlogin.jsp</result> <result name="failure">/login/authorlogin.jsp</result> <result name="success" type="redirect"> countmessage.action?id=${id} </result> </action> <action name="countmessage" class="messageAction" method="countMessagAuthor"> <result name="success">/login/author.html</result> </action> [/code] 再看这个页面的数据展现 [code="java"] <div class="tit" ><img src="../images/045631213.gif" width="16" height="16" vspace="5" align="left" /> &nbsp;用户名:<a href='<s:url action="details"><s:param name = "id" value = "#session.register.id"/></s:url>'> ${session.register.realName}</a></div> [/code] magazineOA/countmessage.action?id=5 第一次登录红色 部分显示在页面上当时就在刷新页面后是${session.register.realName}不再显示。我想是action的问题吧,但是怎么才能把这个为题解决呢? [b]问题补充:[/b] 我想应该是,因为如果我刷新页面的话应该又一次执行countmessage的action,没有执行前面那个action的问题呀,但是应该怎么解决呢?? [b]问题补充:[/b] 本页面刷新后变成这样 [code="java"] <div class="tit" ><img src="../images/045631213.gif" width="16" height="16" vspace="5" align="left" /> &nbsp;用户名:<a href='/magazineOA/login/details.action'> </a> </div> [/code] [b]问题补充:[/b] 我使用的框架。我只刷新这一个页面,那个没有关系吧?????? 这个问题就是在框架里出现好像、。 [b]问题补充:[/b] [code="java"]<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <!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"> body{ padding:0px; margin:0; color:#073a93; background:url(../images/sleftbg.jpg) repeat-y; font-size:12px;} a,area { blr:expression(this.onFocus=this.blur()) } /* for IE */ :focus { outline: none; } .stitle{ background: url(../images/s_title.jpg) no-repeat; width:82px; height:36px; line-height:30px; padding-left:30px; font-weight:bold;} .SleftDiv{margin-left:6px; margin-top:10px; border:solid 1px #7db5ff;width:112px; background-color:#fff;} ul{padding:0; margin:0; list-style:none;} ul li{ width:100px; background:url(../images/s_leftOL.gif) no-repeat 15px 5px;} ul li a{padding-left:30px; line-height:25px; color:#073a93; text-decoration:none;} ul li a:hover{color:#ffcc00;} </style> <title>用户信息</title> </head> <body> <div class="SleftDiv"> <div class="stitle">用户中心</div> <ul> <li><a href='<s:url action="details"><s:param name = "id" value = "#session.register.id"/></s:url>' target="mainFrame">个人信息</a></li> <li><a href='<s:url action="editpass"><s:param name = "id" value = "#session.register.id"/></s:url>' target="mainFrame">修改密码</a></li> <li><a href="index.jsp" target="_top">退出系统</a></li> </ul> </div> <div class="SleftDiv"> <div class="stitle">投 稿 箱</div> <ul> <li><a href="#">我要投稿</a></li> <li><a href="#">草 稿 箱</a></li> <li><a href="#">已投稿件</a></li> <li><a href="#">发表稿件</a></li> </ul> </div> <div class="SleftDiv"> <div class="stitle">信息中心</div> <ul> <li><a href='<s:url action="receiveMessageA"><s:param name="lastreadTime" value="未读" /></s:url>' target="mainFrame">未读信息(${session.count})</a></li> <li><a href='<s:url action="receiveMessageA"></s:url>' target="mainFrame">收 件 箱</a></li> <li><a href='<s:url action="toAuthorSend"></s:url>' target="mainFrame">写&nbsp;&nbsp;&nbsp;&nbsp;信</a></li> <li><a href='<s:url action="sendout"></s:url>' target="mainFrame">已发信件</a></li> <li><a href='<s:url action="tosend"></s:url>' target="mainFrame">写&nbsp;&nbsp;邮&nbsp;&nbsp;件</a></li> </ul> </div> </body> </html> [/code] 这是我的左侧页面的代码 [code="java"] <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <link href="../images/s.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="tit" ><img src="../images/045631213.gif" width="16" height="16" vspace="5" align="left" /> &nbsp;用户名:<a href='<s:url action="details"><s:param name = "id" value = "#session.register.id"/></s:url>'> ${session.register.realName}</a> </div> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder"> <tr> <td><div class="tit_tab">通知公告</div></td> </tr> <tr> <td> <div class="newslist"> <ul> <li><a href="#" target="_blank">科海期刊办公自动化系统《投稿须知》</a></li> <li><a href="#" target="_blank">版权转让协议</a></li> </ul> </div> </td> </tr> </table> <br /> <div id="Tab2"> <div class="Menubox"> <ul> <li id="two1" onclick="setTab('two',1,4)" class="hover">稿签</li> <li id="two2" onclick="setTab('two',2,4)" >内容</li> <li id="two3" onclick="setTab('two',3,4)">作者信息</li> <li id="two4" onclick="setTab('two',4,4)">稿件状态</li> </ul> </div> <div class="Contentbox"> <div id="con_two_1" ><table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabcss"> <tr> <td width="80" align="center">中文文题</td> <td>&nbsp;</td> </tr> <tr> <td align="center">英文文题</td> <td>&nbsp;</td> </tr> <tr> <td align="center">作&nbsp;&nbsp;&nbsp;&nbsp;者</td> <td>&nbsp;</td> </tr> <tr> <td align="center">关&nbsp;键&nbsp;词</td> <td>&nbsp;</td> </tr> <tr> <td align="center">中文摘要</td> <td>&nbsp;</td> </tr> <tr> <td align="center">英文搞要</td> <td>&nbsp;</td> </tr> <tr> <td align="center">回避专家</td> <td>&nbsp;</td> </tr> <tr> <td align="center">推荐专家</td> <td>&nbsp;</td> </tr> <tr> <td align="center">专业类型</td> <td>&nbsp;</td> </tr> </table> </div> <div id="con_two_2" style="display:none">新闻列表2</div> <div id="con_two_3" style="display:none">新闻列表3</div> <div id="con_two_4" style="display:none">新闻列表4</div> </div> </div> <script> <!-- /*第一种形式 第二种形式 更换显示样式*/ function setTab(name,cursel,n){ for(i=1;i<=n;i++){ var menu=document.getElementById(name+i); var con=document.getElementById("con_"+name+"_"+i); menu.className=i==cursel?"hover":""; con.style.display=i==cursel?"block":"none"; } } //--> </script> <br /> <div class="tit" ><img src="../images/045631590.gif" width="16" height="16" vspace="5" align="left" /> &nbsp;已提交的稿件 </div> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablist"> <tr> <th>序号</th> <th>文&nbsp;&nbsp;&nbsp;&nbsp;题 </th> <th>投稿日期</th> <th>稿件状态</th> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> </body> </html> [/code] 这是右侧代码。就是显示夜明那个 我的页面没有其他东西,因为其他只是一个静态没有动态代码使用,贴出来也没有多大帮助呀,[code="java"] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <link href="../images/s.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="tit" ><img src="../images/045631213.gif" width="16" height="16" vspace="5" align="left" /> &nbsp;用户名:<a href='/magazineOA/login/details.action'> </a> </div> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tableborder"> <tr> <td><div class="tit_tab">通知公告</div></td> </tr> <tr> <td> <div class="newslist"> <ul> <li><a href="#" target="_blank">科海期刊办公自动化系统《投稿须知》</a></li> <li><a href="#" target="_blank">版权转让协议</a></li> </ul> </div> </td> </tr> </table> <br /> <div id="Tab2"> <div class="Menubox"> <ul> <li id="two1" onclick="setTab('two',1,4)" class="hover">稿签</li> <li id="two2" onclick="setTab('two',2,4)" >内容</li> <li id="two3" onclick="setTab('two',3,4)">作者信息</li> <li id="two4" onclick="setTab('two',4,4)">稿件状态</li> </ul> </div> <div class="Contentbox"> <div id="con_two_1" ><table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabcss"> <tr> <td width="80" align="center">中文文题</td> <td>&nbsp;</td> </tr> <tr> <td align="center">英文文题</td> <td>&nbsp;</td> </tr> <tr> <td align="center">作&nbsp;&nbsp;&nbsp;&nbsp;者</td> <td>&nbsp;</td> </tr> <tr> <td align="center">关&nbsp;键&nbsp;词</td> <td>&nbsp;</td> </tr> <tr> <td align="center">中文摘要</td> <td>&nbsp;</td> </tr> <tr> <td align="center">英文搞要</td> <td>&nbsp;</td> </tr> <tr> <td align="center">回避专家</td> <td>&nbsp;</td> </tr> <tr> <td align="center">推荐专家</td> <td>&nbsp;</td> </tr> <tr> <td align="center">专业类型</td> <td>&nbsp;</td> </tr> </table> </div> <div id="con_two_2" style="display:none">新闻列表2</div> <div id="con_two_3" style="display:none">新闻列表3</div> <div id="con_two_4" style="display:none">新闻列表4</div> </div> </div> <script> <!-- /*第一种形式 第二种形式 更换显示样式*/ function setTab(name,cursel,n){ for(i=1;i<=n;i++){ var menu=document.getElementById(name+i); var con=document.getElementById("con_"+name+"_"+i); menu.className=i==cursel?"hover":""; con.style.display=i==cursel?"block":"none"; } } //--> </script> <br /> <div class="tit" ><img src="../images/045631590.gif" width="16" height="16" vspace="5" align="left" /> &nbsp;已提交的稿件 </div> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablist"> <tr> <th>序号</th> <th>文&nbsp;&nbsp;&nbsp;&nbsp;题 </th> <th>投稿日期</th> <th>稿件状态</th> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr> </table> </body> </html> [/code] 这是一个输出后查看源代码显示的 还有就是我action的代码 [code="java"]public String countMessagAuthor()throws Exception{ Map<String, Integer> session = ActionContext.getContext().getSession(); Message messag = new Message(); int count; lastreadTime = messag.getLastreadTime(); if(lastreadTime != "未读") { lastreadTime ="未读"; receiveName = id; messag.setLastreadTime(lastreadTime); messag.setSendflag(sendflag); messag.setReceiveName(receiveName); messag.setReceiveflag("0"); List<Message> list = messageService.findByExample(messag); count = list.size(); session.put("count", count); } else { count = 0; session.put("count", count); } return SUCCESS; }[/code] [b]问题补充:[/b] 整个流程很简单的,就是我登陆要调用loginAction action里的方法并且把register用session保存起来,如果我登陆成功后转到执行这个countMessagAuthor方法,进行一些业务操作后跳转我要显示的页面,第一次显示时可以的但是我刷新页面后那个本来该显示session值消息啦 我有三块显示frame,我用的是用spring来管理struts2 的action [b]问题补充:[/b] 不管那个,都是一样的结果。左边,右边,还是整个页面都是这样的。 [b]问题补充:[/b] [code="java"]public String toLogin() throws Exception { try { Map<String, Register> session=ActionContext.getContext().getSession(); register = authorService.loginValid(userName, passWord); if(register !=null){ session.put("register",register); id = register.getId(); return SUCCESS; }else{ addActionError("用户名/密码不匹配"); this.setTip("<font color='red'>对不起您的帐号或密码有误!</font>"); return "failure"; } } catch (Exception e) { // TODO: handle exception this.setTip("<font color='red'>对不起,系统出现故障,请稍后再登录!</font>"); e.printStackTrace(); return "failure"; } } [/code] 这个和我那个要调用的如果是右面刷新时这个没有啦,至于左边那个没有也是一样的好像
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
深析Synchronized关键字(小白慎入,深入jvm源码,两万字长文)
目录一、synchronized基础1.1synchronized的使用1.1示例1.2验证1.2.1 普通方法和代码块中使用this是同一个监视器(锁),即某个具体调用该代码的对象1.2.2 静态方法和代码块中使用该类的class对象是同一个监视器,任何该类的对象调用该段代码时都是在争夺同一个监视器的锁定1.2、synchronized的特点二、synchronized进阶2.1对象头2.2sy
GitHub 总星 4w+!删库?女装?表情包?这些沙雕中文项目真是我每天快乐的源泉!
大家好,我是 Rocky0429,一个喜欢在 GitHub 上瞎逛的蒟蒻… 好看的皮囊千篇一律,有趣的灵魂没有底线。作为全球最大的同性交友网站,GayHub GitHub 上不止有鲜活的代码,秃头的算法,还有很多拥有有(sha)趣(diao)灵魂的宝藏。 还记得我之前给大家介绍的 Sorry 项目嘛,一个可以自己做表情包的项目,这个的沙雕程度在下面这些项目面前只能算弟弟。虽然说沙雕不分国...
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
20道你必须要背会的微服务面试题,面试一定会被问到
这篇博客总结了面试中最常见的微服务面试题,相信对你有所帮助。
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
2020 年,大火的 Python 和 JavaScript 是否会被取而代之?
Python 和 JavaScript 是目前最火的两大编程语言,但是2020 年,什么编程语言将会取而代之呢? 作者 |Richard Kenneth Eng 译者 |明明如月,责编 | 郭芮 出品 | CSDN(ID:CSDNnews) 以下为译文: Python 和 JavaScript 是目前最火的两大编程语言。然而,他们不可能永远屹立不倒。最终,必将像其他编程语言一...
C语言数字图像处理---1.4直方图拉伸和直方图均衡化
本篇将延续上一篇的内容,对直方图进行扩展,讲述直方图拉伸和直方图均衡化两个内容,并通过简单的C语言来实现这两个基础功能,让初学者通俗易懂。
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
没用过这些 IDEA 插件?怪不得写代码头疼
使用插件,可以提高开发效率。对于开发人员很有帮助。这篇博客介绍了IDEA中最常用的一些插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
推荐一些有趣的在线编程游戏
1.Robocode 让坦克们互相博弈的游戏,你可以看到它们飞奔,碾碎一切挡道的东西。机器人配有雷达与火炮,选手在躲避对手进攻的同时攻击对手,以此来较量得分的多少。这个游戏很有意思,曾经令我沉迷… 你可以用Java、Scala、C#等编程语言,编写人工智能程序,驱动机器人。 2.Code Combat Code Combat是一款学习编程的角色扮演游戏。每一关都用任务的形式设立目标,用实时的反馈...
工作十年的数据分析师被炒,没有方向,你根本躲不过中年危机
2020年刚刚开始,就意味着离职潮高峰的到来,我身边就有不少人拿着年终奖离职了,而最让我感到意外的,是一位工作十年的数据分析师也离职了,不同于别人的主动辞职,他是被公司炒掉的。 很多人都说数据分析是个好饭碗,工作不累薪资高、入门简单又好学。然而今年34的他,却真正尝到了中年危机的滋味,平时也有不少人都会私信问我: 数据分析师也有中年危机吗?跟程序员一样是吃青春饭的吗?该怎么保证自己不被公司淘汰...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
张朝阳回应迟到 1 分钟罚 500:资本家就得剥削员工
loonggg读完需要2分钟速读仅需 1 分钟大家我,我是你们的校长。前几天,搜狐的董事局主席兼 CEO 张朝阳和搜狐都上热搜了。原因很简单,就是搜狐出了“考勤新规”。一封搜狐对员工发布...
一个程序在计算机中是如何运行的?超级干货!!!
强烈声明:本文很干,请自备茶水!???? 开门见山,咱不说废话! 你有没有想过,你写的程序,是如何在计算机中运行的吗?比如我们搞Java的,肯定写过这段代码 public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } ...
【蘑菇街技术部年会】程序员与女神共舞,鼻血再次没止住。(文末内推)
蘑菇街技术部的年会,别开生面,一样全是美女。
那个在阿里养猪的工程师,5年了……
简介: 在阿里,走过1825天,没有趴下,依旧斗志满满,被称为“五年陈”。他们会被授予一枚戒指,过程就叫做“授戒仪式”。今天,咱们听听阿里的那些“五年陈”们的故事。 下一个五年,猪圈见! 我就是那个在养猪场里敲代码的工程师,一年多前我和20位工程师去了四川的猪场,出发前总架构师慷慨激昂的说:同学们,中国的养猪产业将因为我们而改变。但到了猪场,发现根本不是那么回事:要个WIFI,没有;...
为什么程序猿都不愿意去外包?
分享外包的组织架构,盈利模式,亲身经历,以及根据一些外包朋友的反馈,写了这篇文章 ,希望对正在找工作的老铁有所帮助
Java校招入职华为,半年后我跑路了
何来 我,一个双非本科弟弟,有幸在 19 届的秋招中得到前东家华为(以下简称 hw)的赏识,当时秋招签订就业协议,说是入了某 java bg,之后一系列组织架构调整原因等等让人无法理解的神操作,最终毕业前夕,被通知调往其他 bg 做嵌入式开发(纯 C 语言)。 由于已至于校招末尾,之前拿到的其他 offer 又无法再收回,一时感到无力回天,只得默默接受。 毕业后,直接入职开始了嵌入式苦旅,由于从未...
世界上有哪些代码量很少,但很牛逼很经典的算法或项目案例?
点击上方蓝字设为星标下面开始今天的学习~今天分享四个代码量很少,但很牛逼很经典的算法或项目案例。1、no code 项目地址:https://github.com/kelseyhight...
​两年前不知如何编写代码的我,现在是一名人工智能工程师
全文共3526字,预计学习时长11分钟 图源:Unsplash 经常有小伙伴私信给小芯,我没有编程基础,不会写代码,如何进入AI行业呢?还能赶上AI浪潮吗? 任何时候努力都不算晚。 下面,小芯就给大家讲一个朋友的真实故事,希望能给那些处于迷茫与徘徊中的小伙伴们一丝启发。(下文以第一人称叙述) 图源:Unsplash 正如Elsa所说,职业转换是...
强烈推荐10本程序员必读的书
很遗憾,这个春节注定是刻骨铭心的,新型冠状病毒让每个人的神经都是紧绷的。那些处在武汉的白衣天使们,尤其值得我们的尊敬。而我们这些窝在家里的程序员,能不外出就不外出,就是对社会做出的最大的贡献。 有些读者私下问我,窝了几天,有点颓丧,能否推荐几本书在家里看看。我花了一天的时间,挑选了 10 本我最喜欢的书,你可以挑选感兴趣的来读一读。读书不仅可以平复恐惧的压力,还可以对未来充满希望,毕竟苦难终将会...
作为一个程序员,内存的这些硬核知识你必须懂!
我们之前讲过CPU,也说了CPU和内存的那点事儿,今天咱就再来说说有关内存,作为一个程序员,你必须要懂的哪那些硬核知识! 大白话聊一聊,很重要! 先来大白话的跟大家聊一聊,我们这里说的内存啊,其实就是说的我们电脑里面的内存条,所以嘞,内存就是内存条,数据要放在这上面才能被cpu读取从而做运算,还有硬盘,就是电脑中的C盘啥的,一个程序需要运行的话需要向内存申请一块独立的内存空间,这个程序本身是存放在...
非典逼出了淘宝和京东,新冠病毒能够逼出什么?
loonggg读完需要5分钟速读仅需 2 分钟大家好,我是你们的校长。我知道大家在家里都憋坏了,大家可能相对于封闭在家里“坐月子”,更希望能够早日上班。今天我带着大家换个思路来聊一个问题...
立即提问