大道至简的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

   privateString username;

   

   privateBlogInfoService 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下载
顶部客服微信二维码底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友