struts2 for javaEE 登录页面跳转问题

刚刚学习JavaEE--SSH框架遇的问题

LoginAction页面如下:

图片说明

src路径下对struts.xml修改如下:

图片说明

输入crazyit.org,leegang后跳转出现错误如下:

图片说明

求各位大师帮帮忙!

2个回答

你的result映射有问题,要结合你的项目、输入的url等等来看
这里有完整的例子,对照看下
http://javatechig.com/java/struts/creating-login-application-using-struts2
http://www.programcreek.com/2010/03/struts-2-tutorials-sample-application-login-module/

zzy20141029
正阳20141029 多谢!
接近 5 年之前 回复

你没有配置servlet-mapping吧

zzy20141029
正阳20141029 恩,谢谢,我会再试试的!
接近 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
struts,javaEE中的地址跳转
跪求: jsp跳转到login.action中老是出现404错误,The requested resource (/Test2/TestActionContext) is not available.在struts的action,class名都核对过,还有可能是什么其他的错吗
struts2没有调用action类自定义的方法,跳转404
一直没有调用action方法,控制台无报错信息,登陆跳转404。 web.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" 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_2_5.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>login.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>*.action</url-pattern> </filter-mapping></web-app> ``` struts.xml: ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <constant name="struts.action.extension" value="true" /> <package name="strut2" extends="struts-default"> <action name="Login" class="loginAction.LoginAction" method="user"> <result name="usersuccess">/user.jsp</result> <result name="adminsuccess">/admin.jsp</result> <result name="fail">/fail.jsp</result> </action> </package> </struts> ``` 试过将method改为函数名称,也试过删去<constant> aciton类: ``` package loginAction; public class LoginAction { private String account; public String getAccount(){ return account; } public void setAccount(String account){ this.account=account; } private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String user()throws Exception{ System.out.print('1'); if(account.equals(password)){ System.out.println("执行user方法"); return "usersuccess"; } return "fail"; } public String admin()throws Exception{ if(account.equals(password)){ System.out.println("执行admin方法"); return "adminsuccess"; } return "fail"; } } ``` 试过删去set,get方法不行,函数没有调用(控制台无1输出) login.jsp ``` <%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> 普通用户登录: <form action = "login-user" method="post"> 请您输入账号:<input name="account" type="text"><br> 请您输入密码:<input name="password" type="password"> <input type="submit" value="登录"> </form><br> 管理员用户登录: <form action = "login-admin" method="post"> 请您输入账号:<input name="account" type="text"><br> 请您输入密码:<input name="password" type="password"> <input type="submit" value="登录"> </form> </body> </html> ``` 试过将action 改为/形式 其他三个登陆成功(失败)页面相似: ``` <%@ page contentType="text/html;charset=UTF-8" language="java" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> 普通用户登陆成功。 </body> </html> ``` 确认struts2包齐全,由myeclipse内部struts2.2.1,struts.xml也在tomcat中的class文件夹中生成
新手,使用Intellij Idea测试Struts2遇到的问题
Idea版本为2018.3,按照提示,Struts2版本为2.5.14,配置完毕,遇到了问题。 第一个问题就是log4j的错误,经过各种尝试,删除out-》artifact-》module-》web-inf-》web.xml,可以正常部署。 然后加入Struts2内容,跳转action时遇到404,请帮忙看看什么问题。 web.xml如下: ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> ``` struts.xml如下: ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <package name="first" namespace="/" extends="struts-default"> <action name="test" class="com.opensymphony.xwork2.ActionSupport" method="execute"> <result name="success">/success.jsp</result> </action> </package> </struts> ``` index.jsp如下: ``` <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>$Title$</title> </head> <body> <form action="test.action" method="post"><input type="submit"/></form> </body> </html> ```
javaEE怎么根据客户端Ip决定跳转到哪个城市?
javaEE怎么根据客户端Ip决定跳转到哪个城市? 首先、怎么根据IP得到城市信息呢? 第二、有没有现成的例子可以参考呢
java的web项目中关于struts2和hibernate的问题。
在我只加入struts2的时候我实现了页面跳转。但是当我加入hibernate后就会报错,不动的求大神指点。 现在贴出代码。 web.xml文件 <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" 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_2_5.xsd"> <display-name></display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!--配置struts2的配置文件--> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilte</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping> <!-- 配置hibernate文档 --> <filter> <filter-name>hibernateFilter</filter-name> <filter-class>info.util.HibernateFilter</filter-class> </filter> <filter-mapping> <filter-name>hibernateFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> struts2.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="true" /> --> <constant name="struts.devMode" value="true"/> <package name="xianshi" extends="struts-default" namespace=""> <action name="xianshi" class="cn.web.user.User"> <result name="success">/add.jsp</result> </action> </package> </struts> ``` hibernate.cfg.xml文件 ``` <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <!-- Generated by MyEclipse Hibernate Tools. --> <hibernate-configuration> <session-factory> <property name="current_session_context_class">thread</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="myeclipse.connection.profile">test</property> <property name="connection.url"> jdbc:mysql://localhost:3306/test </property> <property name="connection.username">root</property> <property name="connection.password">6486178aa</property> <property name="connection.driver_class"> com.mysql.jdbc.Driver </property> <mapping resource="cn/web/service/Users.hbm.xml"/> </session-factory> </hibernate-configuration> ``` 报错文件 ``` 2016-11-3 16:30:29 org.apache.catalina.core.AprLifecycleListener init 信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Users\wzq\MyEclipse\Common\binary\com.sun.java.jdk.win32.x86_64_1.6.0.013\bin;C:\Users\wzq\MyEclipse\Common\plugins\com.genuitec.eclipse.easie.tomcat.myeclipse_9.0.0.me201109141806\tomcat\bin 2016-11-3 16:30:29 org.apache.coyote.http11.Http11Protocol init 信息: Initializing Coyote HTTP/1.1 on http-8080 2016-11-3 16:30:29 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 406 ms 2016-11-3 16:30:29 org.apache.catalina.core.StandardService start 信息: Starting service Catalina 2016-11-3 16:30:29 org.apache.catalina.core.StandardEngine start 信息: Starting Servlet Engine: Apache Tomcat/6.0.13 2016-11-3 16:30:30 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter 2016-11-3 16:30:30 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2016-11-3 16:30:30 org.apache.catalina.core.StandardContext start 严重: Context [/111] startup failed due to previous errors 2016-11-3 16:30:30 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter hibernateFilter java.lang.ClassNotFoundException: info.util.HibernateFilter 2016-11-3 16:30:30 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilte 2016-11-3 16:30:30 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2016-11-3 16:30:30 org.apache.catalina.core.StandardContext start 严重: Context [/web] startup failed due to previous errors 2016-11-3 16:30:31 org.apache.coyote.http11.Http11Protocol start 信息: Starting Coyote HTTP/1.1 on http-8080 2016-11-3 16:30:31 org.apache.jk.common.ChannelSocket init 信息: JK: ajp13 listening on /0.0.0.0:8009 2016-11-3 16:30:31 org.apache.jk.server.JkMain start 信息: Jk running ID=0 time=0/25 config=null 2016-11-3 16:30:31 org.apache.catalina.startup.Catalina start 信息: Server startup in 1459 ms 2016-11-3 16:39:21 org.apache.catalina.startup.HostConfig checkResources 信息: Reloading context [/web] 2016-11-3 16:39:21 org.apache.catalina.core.StandardContext stop 信息: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/web] has not been started 2016-11-3 16:39:21 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter hibernateFilter java.lang.ClassNotFoundException: info.util.HibernateFilter 2016-11-3 16:39:21 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter struts2 java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilte 2016-11-3 16:39:21 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2016-11-3 16:39:21 org.apache.catalina.core.StandardContext start 严重: Context [/web] startup failed due to previous errors ```
请教关于在struts2中传递参数,怎么做,谢谢
我有三个jsp,每个jsp都要填一些字段内容,我现在的做法是在每个jsp的action中将该jsp中的字段存入数据库,但这样存在两个问题,对数据库有压力,另外,在后两个jsp不是很好获得第一个jsp操作数据库时插入新的条目的id,后面就无法对应存入了。 现在,我想jsp1->jsp2>-jsp3,并在jsp3中获得3个jsp的参数,统一将这些 参数 存入数据库,请问如何传参,是否需要三个action呢,谢谢 另外问下,在数据库操作中,比如update xx value(...);之后,如何写SQL语句获得刚刚存入数据库的条目的id呢,谢谢 [b]问题补充:[/b] lovewhzlq 不过三个jsp页面之间的跳转要在同一个请求中跳转 怎么理解 能给出具体的action的配置么,谢谢 [b]问题补充:[/b] 我的前两个jsp表单都很多 [b]问题补充:[/b] lovewhzlq 那是不是三个jsp要请求三次action呀,能给出稍微具体点的配置么,谢谢 [b]问题补充:[/b] 那action的excute方法要执行三次? 可是这样的话我有些值还没传完整呢。。。 [b]问题补充:[/b] 在action中用method配置是么 另外,如果不配置方法,是不是三次执行action就执行三次excute呢 [b]问题补充:[/b] jansel 能具体讲下ScopeInterceptor么,我也想了解,没找到太合适的资源,谢谢 [b]问题补充:[/b] scopeInterceptor 主要起什么作用啊 [b]问题补充:[/b] 我上传了我的工程,数据库也包含在内,不过大家可以把登陆控制取消,改改,要不麻烦 主要有这么几个问题: 1.我在spread.action里面写了4个方法,可是从spread1.jsp->spread2.jsp就会出错,意思是没有input定义,可是我没发现action哪错啦 2.action权限拦截器貌似不起作用,直接进action还是可以,不知道怎么回事 3.登陆页面我启用了<sx:head/>,也配置了验证文件,但貌似无法异步验证,必须提交才行 spread.action [code="java"]package action; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Date; import javax.imageio.ImageIO; import org.apache.struts2.ServletActionContext; import bean.DBUtil; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; public class Spread extends ActionSupport { private static final long serialVersionUID = 1L; public String getLanguage() { return language; } public void setLanguage(String language) { this.language = language; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getTeachpoint() { return teachpoint; } public void setTeachpoint(String teachpoint) { this.teachpoint = teachpoint; } public String getLevel() { return level; } public void setLevel(String level) { this.level = level; } public String getTheme() { return theme; } public void setTheme(String theme) { this.theme = theme; } public String getMedia() { return media; } public void setMedia(String media) { this.media = media; } public String getFullname() { return fullname; } public void setFullname(String fullname) { this.fullname = fullname; } public String getKeyword() { return keyword; } public void setKeyword(String keyword) { this.keyword = keyword; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getIsbn() { return isbn; } public void setIsbn(String isbn) { this.isbn = isbn; } public Date getWritetime() { return writetime; } public void setWritetime(Date writetime) { this.writetime = writetime; } public Date getPublictime() { return publictime; } public void setPublictime(Date publictime) { this.publictime = publictime; } public String getLength() { return length; } public void setLength(String length) { this.length = length; } public String getWidth() { return width; } public void setWidth(String width) { this.width = width; } public String getHeight() { return height; } public void setHeight(String height) { this.height = height; } public String getPages() { return pages; } public void setPages(String pages) { this.pages = pages; } public String getColoredpages() { return coloredpages; } public void setColoredpages(String coloredpages) { this.coloredpages = coloredpages; } public String getWeight() { return weight; } public void setWeight(String weight) { this.weight = weight; } public String getMaterial() { return material; } public void setMaterial(String material) { this.material = material; } public String getIntro() { return intro; } public void setIntro(String intro) { this.intro = intro; } public File[] getUpload() { return upload; } public void setUpload(File[] upload) { this.upload = upload; } public String[] getUploadContentType() { return uploadContentType; } public void setUploadContentType(String[] uploadContentType) { this.uploadContentType = uploadContentType; } public String[] getUploadFileName() { return uploadFileName; } public void setUploadFileName(String[] uploadFileName) { this.uploadFileName = uploadFileName; } public String getSavePath() { return ServletActionContext.getServletContext().getRealPath(savePath); } public void setSavePath(String savePath) { this.savePath = savePath; } public String getChennel() { return chennel; } public void setChennel(String chennel) { this.chennel = chennel; } public String getMarketprice() { return marketprice; } public void setMarketprice(String marketprice) { this.marketprice = marketprice; } public String getSaleprice() { return saleprice; } public void setSaleprice(String saleprice) { this.saleprice = saleprice; } public String getAccess() { return access; } public void setAccess(String access) { this.access = access; } private boolean copy(File src, File dst) { InputStream in = null; OutputStream out = null; try { try { in = new BufferedInputStream(new FileInputStream(src),BUFFER_SIZE); out = new BufferedOutputStream(new FileOutputStream(dst),BUFFER_SIZE); byte[] buffer = new byte[BUFFER_SIZE]; int len = 0; while ((len = in.read(buffer)) > 0) { out.write(buffer, 0, len); } return true; } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } catch(Exception e) { e.printStackTrace(); } return false; } private boolean checkSize(File [] files) { BufferedImage image = null; for (int i = 0; i < files.length; i++) { try { image = ImageIO.read(files[i]); } catch(IOException e) { e.printStackTrace(); } String size = null; if (image.getWidth() > 260 || image.getHeight() > 260) { size ="上传图片宽高不能超过260*260"; ActionContext.getContext().put("size",size); return false; } } return true; } private String getRealPath(String imageString) { return getSavePath() + "\\" + imageString; } public String firstStep() { System.out.println(getLanguage()); System.out.println(getTeachpoint()); System.out.println(getLevel()); System.out.println(getType()); System.out.println(getTheme()); return SUCCESS; } public String secondStep() { System.out.println(getMedia()); System.out.println(getFullname()); System.out.println(getKeyword()); System.out.println(getAuthor()); System.out.println(getIsbn()); System.out.println(getWritetime()); System.out.println(getPublictime()); System.out.println(getLength()); System.out.println(getWidth()); System.out.println(getHeight()); System.out.println(getPages()); System.out.println(getColoredpages()); System.out.println(getWeight()); System.out.println(getMaterial()); System.out.println(getIntro()); return SUCCESS; } public String thirdStep() { File [] files = getUpload(); if (!checkSize(files)) return INPUT; for (int i = 0; i < files.length; i++) { imageFileName = new Date().getTime() + uploadFileName[i].substring(uploadFileName[i].lastIndexOf(".")); File imageFile = new File(getSavePath() + "\\" + imageFileName); copy(files[i],imageFile); realPath[i] = getRealPath(imageFileName); } System.out.println(realPath[0]); System.out.println(realPath[1]); return SUCCESS; } public String forthStep() { return SUCCESS; } private String language; private String type; private String teachpoint; private String level; private String theme; private String media; private String fullname; private String keyword; private String author; private String isbn; private Date writetime; private Date publictime; private String length; private String width; private String height; private String pages; private String coloredpages; private String weight; private String material; private String intro; private static final int BUFFER_SIZE = 16 * 1024; private File[] upload; private String[] uploadContentType; private String[] uploadFileName; private String imageFileName; private String savePath; private String [] realPath = new String[2]; private String chennel; private String marketprice; private String saleprice; private String access; } [/code] struts.xml [code="java"]<?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.i18n.encoding" value="UTF-8"></constant> <constant name="struts.custom.i18n.resources" value="property.message" /> <!--不受权限控制的Action请求配置--> <package name="non-authority" extends="struts-default"> <action name="Login" class="action.LoginCheck"> <result name="success">/spread/spread1.jsp</result> <result name="error">/login.jsp</result> </action> </package> <package name="authority" extends="struts-default"> <interceptors> <interceptor name="authority" class="interceptor.AuthorityInterceptor" /> <interceptor-stack name="mydefault"> <interceptor-ref name="defaultStack" /> <interceptor-ref name="authority" /> </interceptor-stack> </interceptors> <default-interceptor-ref name="mydefault" /> <global-results> <result name="login">/login.jsp</result> </global-results> <action name="FirstStep" class="action.Spread" method="firstStep"> <result name="success">/spread/spread2.jsp</result> </action> <action name="SecondStep" class="action.Spread" method="secondStep"> <result name="success">/spread/spread3.jsp </result> </action> <action name="ThirdStep" class="action.Spread" method="thirdStep"> <result name="success">/spread/spread4.jsp </result> <result name="input">/spread/spread3.jsp </result> <interceptor-ref name="fileUpload"> <param name="allowedTypes">image/jpeg,image/pjpeg</param> <param name="maximumSize">204800</param> </interceptor-ref> <param name="savePath">/upload</param> </action> <action name="ForthStep" class="action.Spread" method="forthStep"> <result name="success">/spread/spreadSucc.jsp</result> </action> </package> </struts> [/code] 权限拦截器 [code="java"]public class AuthorityInterceptor extends AbstractInterceptor { private static final long serialVersionUID = 1L; public String intercept(ActionInvocation invocation) throws Exception { ActionContext ctx = invocation.getInvocationContext(); String user = (String)ctx.getSession().get("username"); System.out.print(user); if (user != null) { return invocation.invoke(); } System.out.print(user); ctx.put("tip", "您还没有登录,请登陆系统"); return Action.LOGIN; } }[/code]怎么才能起作用呢,而且tip值怎么显示出来 web.xml [code="java"]<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" 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_2_5.xsd"> <filter> <filter-name>SetCharacterEncodingFilter</filter-name> <filter-class>filter.SetCharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>SetCharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>accessFilter</filter-name> <filter-class>filter.AccessFilter</filter-class> </filter> <filter-mapping> <filter-name>accessFilter</filter-name> <url-pattern>/spread/*</url-pattern> </filter-mapping> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>struts-cleanup</filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> </filter> <filter-mapping> <filter-name>struts-cleanup</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>dwr</servlet-name> <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>true</param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>dwr</servlet-name> <url-pattern>/dwr/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>modelIndex.jsp</welcome-file> </welcome-file-list> </web-app> [/code] 登陆页面 [code="java"]<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <%@taglib prefix="sx" uri="/struts-dojo-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"> <sx:head/> <title><s:text name="%{getText('loginPage')}" /></title> </head> <body> <div style="color: red"> <s:property value="noUser" /> <s:property value="tip" /> </div> <s:form action="Login" method="post"> <s:textfield label="%{getText('username')}" name="username" value="" cssStyle="width:150px;" /> <s:password label="%{getText('password')}" name="password" cssStyle="width:150px;" /> <sx:submit value="%{getText('login')}" validate="true" /> </s:form> </body> </html>[/code] 谢谢大家
SSH搭建好了之后开始测试Struts的Action 转到自己写的404页面
按照李刚的struts讲义写的action 功能是输入用户名密码之后跳转到另外的jsp页面.但是每次都出来404页面.请问是哪边配置有问题? 如果另外ssh框架也没建好还请指正.以下是代码[code="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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>Archetype Created Web Application</display-name> <!-- 以下3项参数与log4j的配置相关 --> <listener> <listener-class> org.springframework.web.util.Log4jConfigListener </listener-class> </listener> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <context-param> <param-name>log4jRefreshInterval</param-name> <param-value>60000</param-value> </context-param> <!-- 默认情况下,会加载WEB-INF/applicationContext.xml这个文件,我们可以通过配置 contextConfigLocation参数改变配置文件的路径 --> <!-- Spring ApplicationContext配置文件的路径,可使用通配符,多个路径用,号分隔 此参数用于后面的Spring-Context loader --> <!-- 使容器启动时,自动加载applicationContext配置,因为它实现了ServletContextListener这个接口,容器启动时会自动执行它实现的方法。 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:*/ApplicationContext.xml,*/action-Servlet.xml</param-value> </context-param> <!-- 加载spring容器 --> <!-- 整合struts 加入中心拦截器 --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter </filter-class> <init-param> <param-name>struts.action.extendion</param-name> <param-value>action</param-value> </init-param> </filter> <!-- <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>--> <!-- Struts --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts.xml</param-value></init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- session超时定义,单位为分钟 --> <session-config> <session-timeout>120</session-timeout> </session-config> <!-- 默认首页定义 --> <welcome-file-list> <welcome-file>login2.jsp</welcome-file> </welcome-file-list> <!-- Error Page定义 --> <error-page> <exception-type>java.lang.Throwable</exception-type> <location>/commons/error.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/commons/error.jsp</location> </error-page> <error-page> <error-code>404</error-code> <location>/commons/404.jsp</location> </error-page> <error-page> <error-code>403</error-code> <location>/commons/403.jsp</location> </error-page> </web-app> [/code] [code="strut.xml"]<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <constant name="struts.devMode" value="true"/> <constant name="struts.objectFactory" value="spring" ></constant> <package name="calvin" extends="struts-default"> <action name="login" class="/loginAction"> <result name="error">index.jsp</result> <result name="success">/pages/index.jsp</result> </action> </package> </struts>[/code] [code="ApplicationContext.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- Spring容器配置文件 --> <!-- 告诉spring hibernate文件的位置 然后加载 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/policemanagement?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8"/> <property name="username" value="root"/> <property name="password" value="rooot"/> <property name="maxActive" value="100"/> <property name="maxIdle" value="30"/> <property name="maxWait" value="1000"/> <property name="defaultAutoCommit" value="true"/> <property name="removeAbandoned" value="true"/> <property name="removeAbandonedTimeout" value="60"/> <property name="logAbandoned" value="true"/> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources" > <list> <value>calvin/po/pojo/hbm/arrestedPerson.hbm.xml</value> <value>calvin/po/pojo/hbm/caseRegisted.hbm.xml</value> <value>calvin/po/pojo/hbm/caseThread.hbm.xml</value> <value>calvin/po/pojo/hbm/caseVictim.hbm.xml</value> <value>calvin/po/pojo/hbm/policeOfficer.hbm.xml</value> <value>calvin/po/pojo/hbm/victimOffice.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props><prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hbm2ddl.auto">create</prop> </props> </property> </bean> <!-- 为hibernte配置事务管理器 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- daoContext 配置原因 所以放在这边 --> <bean id="dao" class="calvin.dao.imp.BaseDAOHibernate"> <property name="sessionFactory" ref="sessionFactory" /></bean> <bean id="policeOfficerDAO" class="calvin.dao.imp.PoliceOfficerImp"> <property name="sessionFactory" ref="sessionFactory" /></bean> <bean id="arrestedPersonDAO" class="calvin.dao.imp.ArrestedPersonImp"> <property name="sessionFactory" ref="sessionFactory" /></bean> <bean id="caseRegisteredDAO" class="calvin.dao.imp.CaseRegisteredImp"> <property name="sessionFactory" ref="sessionFactory" /></bean> <bean id="caseThreadDAO" class="calvin.dao.imp.CaseThreadImp"> <property name="sessionFactory" ref="sessionFactory" /></bean> <bean id="caseVictimDAO" class="calvin.dao.imp.CaseVictimImp"> <property name="sessionFactory" ref="sessionFactory" /></bean> <bean id="victimOfficeDAO" class="calvin.dao.imp.VictimOfficeImp"> <property name="sessionFactory" ref="sessionFactory" /></bean> <!-- ENd --> <!-- IOC 注入机制 --> <!-- 定义事务模板类 --> <bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <!-- 注入事务管理器 --> <property name="transactionManager" ref="transactionManager"/> <property name="transactionAttributes"> <props> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_REQUIRED,readOnly</prop> </props> </property></bean> <!-- 配置具体业务逻辑层组件的事物代理 --> <bean id="manager" parent="txProxyTemplate"> <property name="target"> <bean class="calvin.service.BaseManager"> <property name="dao" ref="dao"/> </bean> </property> </bean> <!-- 配置具体的业务逻辑组件额事务代理 --> <!-- 配置业务逻辑组件的事务代理,使用了bean 的继承 --> <!-- 配置所需要的dao组件!!!即这里用的是dao的名字 --> <bean id="facadeManager" parent="txProxyTemplate"> <!-- 配置事务代理时,指定代理的目标,此处的目标是嵌套bean--> <property name="target"> <!-- 嵌套bean无须使用 id属性--> <bean class="calvin.service.imp.FacadeManagerImp"> <!-- 为业务逻辑组件注入DAO组件 --> <property name="victimOfficeDAO" ref="victimOfficeDAO"/> <property name="policeOfficerDAO" ref="policeOfficerDAO"/> <property name="caseVictimDAO" ref="caseVictimDAO"/> <property name="caseThreadDAO" ref="caseThreadDAO"/> <property name="caseRegisteredDAO" ref="caseRegisteredDAO"/> <property name="arrestedPersonDAO" ref="arrestedPersonDAO"/> </bean></property> </bean> <!-- action --> <bean id="myService" class="calvin.action.test.MyServiceImp"/> <bean name="/loginAction" class="calvin.action.LoginAction" scope="prototype"> <property name="ms" ref="myService"/> </bean> </beans>[/code] [code="LoginAction"]package calvin.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.junit.Test; import calvin.action.baseAction.BaseAction; import calvin.action.test.MyService; import calvin.po.pojo.PoliceOfficer; public class LoginAction extends BaseAction{ private String username; private String password; private MyService ms; public MyService getMs() { return ms; } public void setMs(MyService ms) { this.ms = ms; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } @Override public String execute() throws Exception{ System.out.println("AAA"); if(ms.valid(getUsername(),getPassword())){ return new String("success"); }else{ return "error";} } } [/code] [code="MyServiceImp"]package calvin.action.test; public class MyServiceImp implements MyService{ public boolean valid(String username,String pass){ return true; } } [/code] 首页配置就是一个很简单的登陆页面.
springmvc跳转页面404问题
(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> <!-- Spring和mybatis的配置文件 --> <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> <!-- Spring监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 防止Spring内存溢出监听器 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- Spring MVC servlet --> <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> <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 --> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> <!-- 配置SESSION超时,单位是分钟 --> <session-config> <session-timeout>15</session-timeout> </session-config> </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" 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.cn.hnust.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> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> <!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> JSON转换器 </list> </property> </bean> --> <mvc:annotation-driven></mvc:annotation-driven> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <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:component-scan base-package="com.cn.hnust" /> <!-- 引入配置文件 --> <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="${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" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/cn/hnust/mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.cn.hnust.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> <controller> package com.test.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.test.pojo.User; import com.test.service.UserService; @Controller @RequestMapping(value="user") public class UserController { // private UserService userService; @RequestMapping(value="test") public String test() { User user = new User(); System.out.println("11111111111111111111111"); return "index"; } } 实在没办法最后我只做了一个简单的页面跳转,还是报404,
action="/user" 不跳转到根目录
框架是struts1.3 jsp在form文件夹下 本来应该跳转到根目录的 但是url每次都跳转到/form/user?... . . 下面是相关代码 . . . signin.jsp,放在webroot/form文件夹下。 (form那块第一部分注释掉的是原本用struts的html标签做的,这个是可以正常跳转的。但我想用普通的html标签,但就是不行。。) ``` <%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <html> <head> <title>JSP for UserForm form</title> </head> <body> <%-- <html:form action="/user"> <html:hidden property="action" value="signin"/> 账号 : <html:text property="account"/><html:errors property="account"/><br/> 密码 : <html:password property="pwd"/><html:errors property="pwd"/><br/> <html:submit/><html:cancel/> </html:form> --%> <form action="/user"> 账户 : <input type="text" name="account" value="admin1"><br> 密码 : <input type="text" name="pwd" value="1q!"><br> <input type="submit" value="Submit"> </form> </body> </html> ``` struts-config ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> <struts-config> <form-beans > <form-bean name="userForm" type="com.changhe.struts.form.UserForm" /> </form-beans> <global-exceptions /> <global-forwards /> <action-mappings > <action attribute="userForm" input="/form/signin.jsp" name="userForm" path="/user" scope="request" type="com.changhe.struts.action.UserAction" cancellable="true"> <forward name="failure" path="/result/failure.jsp" /> <forward name="success" path="/result/success.jsp" /> </action> </action-mappings> <message-resources parameter="com.changhe.struts.ApplicationResources" /> </struts-config> ``` 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>ncdba2_0</display-name> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>3</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>3</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app> ```
springmvc+mybatis整合maven项目跳转页面404问题
controller package com.cn.hnust.controller; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import com.cn.hnust.pojo.User; import com.cn.hnust.service.IUserService; @Controller @RequestMapping("/user") public class UserController { @Resource private IUserService userService; @RequestMapping("/showUser") public String toIndex(HttpServletRequest request,Model model){ int userId = Integer.parseInt(request.getParameter("id")); User user = this.userService.getUserById(userId); model.addAttribute("user", user); return "showUser"; } } 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> <!-- Spring和mybatis的配置文件 --> <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> <!-- Spring监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 防止Spring内存溢出监听器 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- Spring MVC servlet --> <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> <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 --> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> <!-- 配置SESSION超时,单位是分钟 --> <session-config> <session-timeout>15</session-timeout> </session-config> </web-app> springmvc-mybatis <?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:component-scan base-package="com.cn.hnust" /> <!-- 引入配置文件 --> <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="${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" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/cn/hnust/mapping/*.xml"></property> </bean> <!-- DAO接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.cn.hnust.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> 大神们帮忙看看哪里出错了,谢谢
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)
Spring MVC 视图问题,访问 jsp 却返回字符串,紧急求助!
## war 包结构如下: ![图片说明](https://img-ask.csdn.net/upload/201712/11/1512999813_263311.png) ## 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: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.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.lvmama.ptest.controller" /> <!-- 开启注解 --> <mvc:annotation-driven /> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> <!-- 配置静态资源,直接映射到对应的文件夹,不被DispatcherServlet处理,3.04新增功能,需要重新设置spring-mvc-3.0.xsd --> <mvc:resources mapping="/img/**" location="/img/" /> <mvc:resources mapping="/js/**" location="/js/" /> <mvc:resources mapping="/css/**" location="/css/" /> <mvc:resources mapping="/html/**" location="/html/" /> </beans> ## web.xml 配置如下: <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" 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_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- 加载Spring容器配置 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 设置Spring容器加载所有的配置文件的路径 --> <context-param> <param-name>contextConfigLocation</param-name> <!-- <param-value>classpath:config/spring-*.xml</param-value> --> <param-value>classpath:applicationContext-service.xml</param-value> </context-param> <!-- 配置SpringMVC核心控制器 --> <servlet> <servlet-name>ptest_controller</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 配置初始配置化文件,前面contextConfigLocation看情况二选一 --> <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> <!--为DispatcherServlet建立映射 --> <servlet-mapping> <servlet-name>ptest_controller</servlet-name> <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 --> <url-pattern>/</url-pattern> </servlet-mapping> <!-- 防止Spring内存溢出监听器 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- 解决工程编码过滤器 --> <filter> <filter-name>encodingFilter</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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> 通过Controller 层访问jsp 页面,返回的是字符串“index” ![图片说明](https://img-ask.csdn.net/upload/201712/12/1513044114_362787.png) 但是输入jsp 以外的请求,又能正常访问: ![图片说明](https://img-ask.csdn.net/upload/201712/11/1513000331_464970.png) 请各位帮帮忙解答,十分感谢!!!! 对应的controller class 如下: @Controller public class PtestProjectController { @Autowired private PtestProjectService ptestprojectservice; @RequestMapping("/project/list/{id}") @ResponseBody public PtestProject getProjectById(@PathVariable int id) throws Exception{ PtestProject result = ptestprojectservice.getProjectById(id); return result; } @RequestMapping("/index") @ResponseBody public String getIndex() throws Exception{ return "index"; } } 为什么不返回jsp页面?
maven springMvc 扫描不到注解controller
``` <?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.3.xsd"> <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <context:component-scan base-package="cn.com" use-default-filters="false"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/> </context:component-scan> <mvc:annotation-driven> <!--<mvc:async-support default-timeout="300000"/>--> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" /> <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg value="UTF-8" /> </bean> </mvc:message-converters> </mvc:annotation-driven> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <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> ``` ``` <?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/*.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> <!-- Spring监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 防止Spring内存溢出监听器 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- Spring MVC servlet --> <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/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> <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 --> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> </web-app> ``` ``` package cn.com.base.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * * @author Mr.Xu * @date * */ @Controller @RequestMapping("/user") public class UserController { /** * 测试 * @author Mr.Xu * @date * @return */ @RequestMapping(value = "/goLogin", method = { RequestMethod.POST,RequestMethod.GET }) public String goUser() { return "login"; } } ```
刚搭的ssm框架,不能直接通过url访问WEB-INF下的html
如下图,我不能直接通过地址栏的url去访问HTML页面. ![图片说明](https://img-ask.csdn.net/upload/201708/09/1502243574_813631.png) 以下是我的配置: # 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> <!-- Spring和mybatis的配置文件 --> <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> <!-- Spring监听器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 防止Spring内存溢出监听器 --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <!-- Spring MVC servlet --> <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> <!-- 此处可以可以配置成*.do,对应struts的后缀习惯 --> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app> # 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" 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-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 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd "> <!-- <context:annotation-config /> --> <!-- 自动扫描 --> <!-- <context:component-scan base-package="com.lizhm" /> --> <context:component-scan base-package="**.*.services"/> <!-- 引入配置文件 --> <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" > <property name="driverClassName" value="${jdbc.driverClassName}" /> <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*:/**/*Mapper.xml"></property> </bean> <!-- DAO(services)接口所在包名,Spring会自动查找其下的类 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="**.*.mapper" /> <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> <!-- 配置基于注解的声明式事务 --> <tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven> </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: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/> <!-- 自动扫描该包,使SpringMVC认为包下用了@controller注解的类是控制器 --> <context:component-scan base-package="**.*.controllers" /> <!--避免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> <!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 --> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="messageConverters"> <list> <ref bean="mappingJacksonHttpMessageConverter" /> <!-- JSON转换器 --> </list> </property> </bean> <!-- 配置SpringMVC --> <!-- 1.开启SpringMVC注解模式 --> <!-- 简化配置: (1)自动注册DefaultAnootationHandlerMapping,AnotationMethodHandlerAdapter (2)提供一些列:数据绑定,数字和日期的format @NumberFormat, @DateTimeFormat, xml,json默认读写支持 --> <mvc:annotation-driven/> <!-- 2.静态资源默认servlet配置 (1)加入对静态资源的处理:js,gif,png (2)允许使用"/"做整体映射 --> <mvc:default-servlet-handler/> <!-- <mvc:resources mapping="/lib/**" location="/lib/" /> --> <mvc:resources mapping="/resources/**" location="/resources/" /> <!-- <mvc:resources mapping="/WEB-INF/view/**" location="/WEB-INF/view/" /> --> <!-- 定义跳转的文件的前后缀 ,视图模式配置--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> --> <!-- 这里的配置我的理解是自动给后面action的方法return的字符串加上前缀和后缀,变成一个 可用的url地址 --> <property name="prefix" value="/WEB-INF/view/" /> <property name="suffix" value=".html" /> </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>
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
JSON解析——net.sf.json.JSONObject
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
卸载 x 雷某度!GitHub 标星 1.5w+,从此我只用这款全能高速下载工具!
作者 | Rocky0429 来源 | Python空间 大家好,我是 Rocky0429,一个喜欢在网上收集各种资源的蒟蒻… 网上资源眼花缭乱,下载的方式也同样千奇百怪,比如 BT 下载,磁力链接,网盘资源等等等等,下个资源可真不容易,不一样的方式要用不同的下载软件,因此某比较有名的 x 雷和某度网盘成了我经常使用的工具。 作为一个没有钱的穷鬼,某度网盘几十 kb 的下载速度让我...
2019年还剩1天,我从外包公司离职了
这日子过的可真快啊,2019年还剩1天,外包公司干了不到3个月,我离职了
我一个37岁的程序员朋友
周末了,人一旦没有点事情干,心里就瞎想,而且跟几个老男人坐在一起,更容易瞎想,我自己现在也是 30 岁了,也是无时无刻在担心自己的职业生涯,担心丢掉工作没有收入,担心身体机能下降,担心突...
计算机网络的核心概念
这是《计算机网络》系列文章的第二篇文章 我们第一篇文章讲述了计算机网络的基本概念,互联网的基本名词,什么是协议以及几种接入网以及网络传输的物理媒体,那么本篇文章我们来探讨一下网络核心、交换网络、时延、丢包、吞吐量以及计算机网络的协议层次和网络攻击。 网络核心 网络的核心是由因特网端系统和链路构成的网状网络,下面这幅图正确的表达了这一点 那么在不同的 ISP 和本地以及家庭网络是如何交换信息的呢?...
python自动下载图片
近日闲来无事,总有一种无形的力量萦绕在朕身边,让朕精神涣散,昏昏欲睡。 可是,像朕这么有职业操守的社畜怎么能在上班期间睡瞌睡呢,我不禁陷入了沉思。。。。 突然旁边的IOS同事问:‘嘿,兄弟,我发现一个网站的图片很有意思啊,能不能帮我保存下来提升我的开发灵感?’ 作为一个坚强的社畜怎么能说自己不行呢,当时朕就不假思索的答应:‘oh, It’s simple. Wait for me for a ...
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
程序员如何通过造轮子走向人生巅峰?
前言:你所做的事情,也许暂时看不到成果。但不要灰心,你不是没有成长,而是在扎根。 程序员圈经常流行的一句话:“不要重复造轮子”。在计算机领域,我们将封装好的组件、库,叫做轮子。因为它可以拿来直接用,直接塞进我们的项目中,就能实现对应的功能。 有些同学会问,人家都已经做好了,你再来重新弄一遍,有什么意义?这不是在浪费时间吗。 殊不知,造轮子是一种学习方式,能快速进步,造得好,是自己超强能力的表...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试一个ArrayList我都能跟面试官扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
Idea 中最常用的10款插件(提高开发效率),一定要学会使用!
学习使用一些插件,可以提高开发效率。对于我们开发人员很有帮助。这篇博客介绍了开发中使用的插件。
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
最全最强!世界大学计算机专业排名总结!
我正在参与CSDN200进20,希望得到您的支持,扫码续投票5次。感谢您! (为表示感谢,您投票后私信我,我把我总结的人工智能手推笔记和思维导图发送给您,感谢!) 目录 泰晤士高等教育世界大学排名 QS 世界大学排名 US News 世界大学排名 世界大学学术排名(Academic Ranking of World Universities) 泰晤士高等教育世界大学排名 中国共...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
那些年,我们信了课本里的那些鬼话
教材永远都是有错误的,从小学到大学,我们不断的学习了很多错误知识。 斑羚飞渡 在我们学习的很多小学课文里,有很多是错误文章,或者说是假课文。像《斑羚飞渡》: 随着镰刀头羊的那声吼叫,整个斑羚群迅速分成两拨,老年斑羚为一拨,年轻斑羚为一拨。 就在这时,我看见,从那拨老斑羚里走出一只公斑羚来。公斑羚朝那拨年轻斑羚示意性地咩了一声,一只半大的斑羚应声走了出来。一老一少走到伤心崖,后退了几步,突...
立即提问