在嵌入式jetty环境下运行struts2Annotation项目

本人采用struts2的注解,配置好后可以在tomcat下运行,但是使用嵌入式jetty运行时,总是出现无法找到action的问题。

package com.action;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionSupport;

@Namespace(value="/tt")
@ParentPackage(value="struts-default")
@Results(
   {
   @Result(name="success",location="/hello.jsp"),
   @Result(name="error",location="/hello.jsp")
   })
public class HelloAction extends ActionSupport{

	private String username;
	private String password;
	
	private String result;
	
	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	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;
	}

	public String execute() throws Exception {
		result =this.getClass().getSimpleName();
		return SUCCESS;
	}
	
	/**
	 * @return
	 * @throws Exception
	 */
	@Action(value="login",results={
			@Result(name="success",location="/hello.jsp"),
			@Result(name="error",location="/hello.jsp")
	})
	public String login()throws Exception{
		result =this.getClass().getSimpleName()+ username+":"+password;
		return SUCCESS;
	}
}

 //========================================================================
//Copyright 2007 Mort Bay Consulting Pty. Ltd.
//------------------------------------------------------------------------
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//========================================================================

package jetty;

import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

public class OneWebApp
{
    public static void main(String[] args) throws Exception
    {
        String jetty_home = "jetty";
        int port = 8020;

        Server server = new Server();
        
        Connector connector=new SelectChannelConnector();
        connector.setPort(port);
        server.addConnector(connector);
        
        WebAppContext webapp = new WebAppContext( "WebRoot", "/web");
        
        server.setHandler(webapp);
        
        server.start();
    }
}

求指导。。。。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值