Skip to content

Commit

Permalink
修改后台管理shiro设置错误
Browse files Browse the repository at this point in the history
  • Loading branch information
pzhgugu committed Jul 8, 2016
1 parent 1024090 commit 79a7a05
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ public String get(String key) {
try{
value = jedis.get(key);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return value;
}
Expand All @@ -32,9 +35,12 @@ public byte[] get(byte[] key) {
try{
value = jedis.get(key);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return value;
}
Expand All @@ -45,9 +51,12 @@ public String set(String key, String value) {
try {
value = jedis.set(key, value);
}catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return value;
}
Expand All @@ -61,9 +70,12 @@ public String set(String key, String value, int expire) {
jedis.expire(key, expire);
}
}catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return value;
}
Expand All @@ -75,9 +87,12 @@ public String set(byte[] key, byte[] value) {
try {
v =jedis.set(key, value);
}catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return v;
}
Expand All @@ -92,9 +107,12 @@ public String set(byte[] key, byte[] value, int expire) {
jedis.expire(key, expire);
}
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return v;
}
Expand All @@ -106,9 +124,12 @@ public String hget(String hkey, String key) {
try{
value = jedis.hget(hkey, key);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return value;
}
Expand All @@ -120,9 +141,12 @@ public long hset(String hkey, String key, String value) {
try{
result= jedis.hset(hkey, key, value);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return result;
}
Expand All @@ -134,9 +158,12 @@ public long incr(String key) {
try{
result = jedis.incr(key);
}catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return result;
}
Expand All @@ -148,9 +175,12 @@ public long expire(String key, int second) {
try{
result = jedis.expire(key, second);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return result;
}
Expand All @@ -162,9 +192,12 @@ public long ttl(String key) {
try{
result = jedis.ttl(key);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return result;
}
Expand All @@ -176,9 +209,12 @@ public long del(String key) {
try{
result = jedis.del(key);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return result;
}
Expand All @@ -190,9 +226,12 @@ public long del(byte[] key) {
try{
result = jedis.del(key);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return result;
}
Expand All @@ -204,9 +243,12 @@ public long hdel(String hkey, String key) {
try{
result = jedis.hdel(hkey, key);
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return result;
}
Expand All @@ -223,9 +265,12 @@ public Set<byte[]> keys(String pattern) {
try {
keys = jedis.keys(pattern.getBytes("utf-8"));
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return keys;
}
Expand All @@ -236,9 +281,12 @@ public void flushDB() {
try {
jedis.flushDB();
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
}

Expand All @@ -249,9 +297,12 @@ public Long dbSize() {
try {
dbSize = jedis.dbSize();
} catch (Exception e) {
jedisPool.returnBrokenResource(jedis);
//jedisPool.returnBrokenResource(jedis);
} finally {
jedisPool.returnResource(jedis);
//jedisPool.returnResource(jedis);
if(null != jedis){
jedis.close();
}
}
return dbSize;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package org.goshop.email.service;

import org.goshop.email.pojo.MailParam;
import org.goshop.email.utils.SimpleMailSender;
import org.goshop.email.i.EMailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import javax.mail.MessagingException;

@Service("eMailService")
public class EMailServiceImpl implements EMailService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import org.goshop.email.i.EMailService;
import org.goshop.email.pojo.MailParam;
import org.goshop.email.utils.SimpleMailSender;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.goshop.base.service.SpringBaseTest;

import javax.mail.MessagingException;

/**
* Created by Administrator on 2016/6/21.
Expand All @@ -20,19 +18,19 @@ public class EMailServiceImplTest extends SpringBaseTest {
@Test
public void testSend() throws Exception {

SimpleMailSender sms = new SimpleMailSender("[email protected]","pzh1234567");
/* SimpleMailSender sms = new SimpleMailSender("[email protected]","pzh1234567");
try {
sms.send("[email protected]","找回密码","你来吧!");
} catch (MessagingException e) {
e.printStackTrace();
}
}*/
}

@Test
public void threadSpringSend(){
MailParam mail = new MailParam();
mail.setTo("[email protected]");
mail.setSubject("找回密码");
mail.setSubject("找回密码2");
mail.setContent("你来吧!");
eMailService.threadSend(mail);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<property name="securityManager" ref="securityManager" />
<!-- loginUrl认证提交地址,如果没有认证将会请求此地址进行认证,请求此地址将由formAuthenticationFilter进行表单认证 -->
<property name="loginUrl" value="/login.do" />
<!-- 认证成功统一跳转到first.action,建议不配置,shiro认证成功自动到上一个请求路径
<property name="successUrl" value="/first"/>-->
<!-- 认证成功统一跳转到first.action,建议不配置,shiro认证成功自动到上一个请求路径-->
<property name="successUrl" value="/home"/>
<!-- 通过unauthorizedUrl指定没有权限操作时跳转页面-->
<property name="unauthorizedUrl" value="/refuse.html" />
<property name="unauthorizedUrl" value="/refuse" />

<!-- 自定义filter配置 -->
<property name="filters">
Expand All @@ -36,22 +36,24 @@
<property name="filterChainDefinitions">
<value>
<!-- 对静态资源设置匿名访问 -->
/validationCodeServlet.png**= anon
/static/** = anon
/validationCodeServlet.png = anon
/refuse = anon
/att**=anon
<!-- 请求 logout.action地址,shiro去清除session-->
/logout = logout
/login.do = authc
/store_join/** = authc
/member/** = authc
<!-- /** = authc 所有url都必须认证通过才可以访问
/home = -->
/** = anon
<!--/** = perms[admin:read]-->
/** = roles[admin]
<!-- /** = anon所有url都可以匿名访问 -->

</value>
</property>
</bean>


<!-- securityManager安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="customRealm" />
Expand Down

0 comments on commit 79a7a05

Please sign in to comment.