大道至简的gravatar头像
大道至简 2017-02-04 13:23:00

ssh框架开发的java个人博客系统-BFblogDemo07

ssh框架开发的java个人博客系统-BFblogDemo07

问题一:点击文章后,该用户的个性化设置并没有显示。

解决方案:

1.在显示所有文章页添加一个参数,为用户名。

<a href="user/showArticle.action?username=<s:property value='#art.username'/>&id=<s:property value='#art.id'/>"><s:property value="#art.title"/></a>

传递参数的目的在于,在文章内容页面中,通过查询该用户个性化设置,并显示。

 

2.设置ShowArticle

    //username

    private String username;

   

    private BlogInfoService blogInfoService;

 

       //取得个性化设置

       //通过业务逻辑组件来查询

       if(username != null || !"".equals(username)) {

           Map session = ActionContext.getContext().getSession();

           BlogInfo bloginfo  = blogInfoService.getBlogInfo(username);

           if(bloginfo != null) {

              session.put("blogtitle", bloginfo.getBlogtitle());

              session.put("idiograph", bloginfo.getIdiograph());

           }

       }

 

问题二:不能正常显示用户所有文章。

解决方案:

1.修改头部文件。

<%@ page language="java" contentType="text/html; charset=gb2312"

    pageEncoding="gb2312"%>

<!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=gb2312" />

<title>无标题文档</title>

<script language="javascript">

<!--

function mhEnter()

{

window.event.srcElement.className="lt1";

}

function mhLeave()

{

window.event.srcElement.className="lt0";

}

//-->

</script>

<link rel="stylesheet" href="image/style.css"/>

<style type="text/css">

<!--

.blogtitle {

    font-size: 18px;

    font-weight: bold;

}

.idiograph {

    position: relative;

    left: 50px;

}

 

-->

</style>

</head>

 

<body>

<table width="1000" border="0" cellpadding="0" cellspacing="0" align="center">

    <tr>

       <td background="image/bg1.jpg" height="150">

       <!-- 博客标题位置-->

       <span class="blogtitle">${sessionScope.blogtitle}</span><br />

      <span class="idiograph">${sessionScope.idiograph}     </span>      <!-- 个性签名位置-->       </td>

    </tr>

    <tr height="31">

       <td background="../image/line.jpg">

           <table width="1000" border="0" cellpadding="0" cellspacing="0">

              <%

                  String username = request.getParameter("username");

                  if(username == null || "".equals(username)) {

               %>

             

              <tr height="20" align="center">

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="../showAllArticle.action">北风博客首页</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="showUserAllArticle.action">用户首页</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="editbloginfo.jsp">个性化设置</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="addArticle.jsp">写日志</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="showPhoto.action">相册</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="../index.html">留言板</a></td>

              </tr>

              <%

                  } else {

               %>

               

                  <tr height="20" align="center">

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="../showAllArticle.action">北风博客首页</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="showUserAllArticle.action?username=${param.username }">用户首页</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="editbloginfo.jsp">个性化设置</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="addArticle.jsp">写日志</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="showPhoto.action">相册</a></td>

                  <td class="ltsep">|</td>

                  <td class="lt0" onmouseenter="mhEnter()" onmouseleave="mhLeave()"><a href="../index.html">留言板</a></td>

              </tr>

               <%

                  }

                %>

           </table>

       </td>

    </tr>

</table>

</body>

</html>

 

 

 

2.修改ShowUserAllArticle

       private String username;

 

       if(username == null || "".equals(username)) {

           //首先要获得session

           Map session = ActionContext.getContext().getSession();

           //获得username

           username = (String) session.get("username");

       }

 

问题三:显示文章页面底部不正确。

                                                 <%

                                                     String username = request.getParameter("username");

                                                     if(username == null || "".equals(username)) {

                                                  %>

                                                     ${sessionScope.username}的博客

                                                 <%

                                                     } else {

                                                 %>

                                                      ${param.username }的博客

                                                 <%

                                                     }

                                                  %>

 

问题四:相册的显示,和博客文章显示是完全一样的。(留给大家来完善)


打赏

已有2人打赏

cuijinchuan的gravatar头像 gvsfdvsrvr的gravatar头像

文件名:BFblogDemo07.rar,文件大小:19746.094K 下载
最代码最近下载分享源代码列表最近下载
aaaaaaa3333  LV1 2022年5月18日
SOLEIL.  LV3 2021年6月19日
yyyyyyuuuuuu  LV1 2021年2月14日
无情先生3333  LV2 2020年12月29日
skook7  LV2 2020年7月26日
lwp011  LV27 2020年7月7日
1515355665  LV7 2020年7月2日
王步庆  LV9 2020年5月14日
小陆啊  LV2 2020年3月8日
12432423  LV2 2019年12月18日
最代码最近浏览分享源代码列表最近浏览
最代码的苏拉 9月22日
暂无贡献等级
周敏国  LV9 8月21日
Tomcat80  LV4 6月25日
暂无贡献等级
陆程江  LV2 5月28日
yzshabzbbdvw  LV4 5月15日
3516569014  LV5 5月7日
Ali200930  LV2 3月28日
1516667367 3月19日
暂无贡献等级
yiangeee  LV9 3月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友