写了一个带登录的系统,本来打包成war放在阿里云centos的tomcat的webapps下,通过ip:8080/项目名是可以所有正常显示并没有一点差错的。
       但我想把域名映射过去,于是出问题了,登录跳转界面后显示:
The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml or the jar files deployed with this application
这个登录是通过springmvc执行并跳转的:如下
@RequestMapping("/login")
public ModelAndView loginStudent(@RequestParam("sid") String sid,@RequestParam("spassword") String spassword,Model model,HttpSession httpSession) {
StudentDAO studentDAO = new StudentDAO();
Student student = new Student();
student = studentDAO.getByStuSid(sid);
if (studentDAO.queryByNamePwd(sid, spassword)) {
            httpSession.setAttribute("sid", sid);
            httpSession.setAttribute("sname", student.getSname());
            return new ModelAndView(new RedirectView("../student/studentFace.jsp"));   /////在这里的确跳转成功,因为url显示出来了
        } else {
         return new ModelAndView(new RedirectView("../fail.jsp"));
        }

}
还有一个登录却是可以登录成功的,
@RequestMapping("/login")
public String loginStudent(@RequestParam("aname") String aname,@RequestParam("apassword") String apassword,Model model,HttpSession httpSession) {
AdminDAO adminDAO = new AdminDAO();
if (adminDAO.queryByNamePwd(aname, apassword)) {
httpSession.setAttribute("aname", aname);
            return "admin/adminFace";
        } else {
            return "fail";
        }
}
但跳转之后的界面没有cssjs图片直接了,并且跳转之后界面的超链接点击之后显示错误:Message /onlineSC/StudentController/managestuDescription The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
上两张图,第一张:是第一种登录后直接显示的错误,
第二张是第二种可以登录进去的,第三张是第二张超链接点进去之后的
还有这两种登录跳转过去的界面都有这条语句
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>这些不用域名,直接通过ip:8080/项目名访问是很正常的,郁闷了一天,也百度了一天,实在想不出办法了 有没有技术大佬帮帮忙还有我的tomcat配置:
截取一段
<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
       <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    <Engine name="Catalina" defaultHost="localhost">      
      <Realm className="org.apache.catalina.realm.LockOutRealm">
       
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>      <Host name="onlinesc.fuzui.net" appBase="/www/server/tomcat/webapps/onlineSC" unpackWARs="true" autoDeploy="true">
  <Context path="" docBase="/www/server/tomcat/webapps/onlineSC" debug="0" reloadable="true" />
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  </Host>有点头大

解决方案 »

  1.   

    找到原因了 ,功夫不负有心人,tomcat的server.xml配置出错,花了好长时间弄懂了appBase和docBase,上面server配置文件中appBase写到了具体项目中,导致css、js以及控制器类中的跳转无法到项目名的那一级目录,在网上找了这两个的含义:appBase这个目录下面的子目录将自动被部署为应用,且war文件将被自动解压缩并部署为应用;docBase只是指向了你某个应用的目录。为了防止发生变化,又把原有的<Host name="location" appBase="webapps" unpackWARs="true" autoDeploy="true">这条命令加了回去(一开始删了)。还是自己学的太浅,积累经验。